1. 程式人生 > >eclipse建立maven專案常見錯誤

eclipse建立maven專案常見錯誤

  1. 包掃描書寫錯誤
    當包掃描寫成 com.java.controller.* 的時候,並不包括controller包下的類,只會掃描controller包下子包中的類在這裡插入圖片描述
  2. spring3.2版本不支援jdk1.8,只能到jdk1.7
嚴重: StandardWrapper.Throwable
org.springframework.beans.factory.BeanDefinitionStoreException:
 Failed to read candidate component class: 
 file[D:\JAVA\tomcat\apache-tomcat-8.0.52\webapps\hotel-admin\WEB-INF\classes\com\java\controller\LoginController.class];
 nested exception is org.springframework.core.NestedIOException: 
 ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet:
 file [D:\JAVA\tomcat\apache-tomcat-8.0.52\webapps\hotel-admin\WEB-INF\classes\com\java\controller\LoginController.class]; 
 nested exception is java.lang.IllegalArgumentException
	at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:281)
	at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
	at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)

	at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
	
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.core.NestedIOException: 
ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: 
file [D:\JAVA\tomcat\apache-tomcat-8.0.52\webapps\hotel-admin\WEB-INF\classes\com\java\controller\LoginController.class]; 
nested exception is java.lang.IllegalArgumentException
	at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:56)
	at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
	at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
	at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:257)
	... 39 more
Caused by: java.lang.IllegalArgumentException
	at org.springframework.asm.ClassReader.<init>(Unknown Source)
	at org.springframework.asm.ClassReader.<init>(Unknown Source)
	at org.springframework.asm.ClassReader.<init>(Unknown Source)
	at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:53)
	... 42 more

一月 10, 2019 4:30:40 下午 org.apache.catalina.core.StandardContext loadOnStartup
嚴重: Servlet [dispatcherServlet] in web application [/hotel-admin] threw load() exception
java.lang.IllegalArgumentException
	at org.springframework.asm.ClassReader.<init>(Unknown Source)
	at org.springframework.asm.ClassReader.<init>(Unknown Source)
	at org.springframework.asm.ClassReader.<init>(Unknown Source)
	at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:53)
	at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
	at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
	
	...省略些異常...

解決辦法:把該war專案的jdk1.8改為1.7的
在這裡插入圖片描述
下一步
在這裡插入圖片描述
重啟tomcat伺服器。