学习开发,一定要用教程里一样的开发环境。
如果不能一样也要尽量减少差别。
为什么这么说,因为N多次的开发学习中的教训告诉我,一味追求最新开发环境,没什么别的好处,
只会给自己带来想象不到麻烦。比如视频教学中开发好好的,你按着做就出现莫名其妙的bug,这些
bug会费你几个小时或1天的时间去处理,有时还不一定能搞定。这太浪费时间了。下面是我最近的例子:
这是视频开发(spring项目)环境要求:
我追求新的,就用 jdk 1.8.*** 。结果呢jdk1.8与开发中使用的spring 3.2不兼容,起初不知道,就出现了以下bug:
1.
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from
relative location [config/*.xml]
Offending resource: class path resource [application-context.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException:
Failed to read candidate component class: file [D:\install\apache-tomcat-7.0.70\webapps\babasport12\WEB-INF\classes\cn\itcast\common\junit\SpringJunitTest.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:\install\apache-tomcat-7.0.70\webapps\babasport12\WEB-INF\classes\cn\itcast\common\junit\SpringJunitTest.class];
nested exception is
java.lang.IllegalArgumentException
2.
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file
[D:\install\apache-tomcat-7.0.70\webapps\babasport12\WEB-INF\classes\cn\itcast\common\junit\SpringJunitTest.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:\install\apache-tomcat-7.0.70\webapps\babasport12\WEB-INF\classes\cn\itcast\common\junit\SpringJunitTest.class];
3.
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:\install\apache-tomcat-7.0.70\webapps\babasport12\WEB-INF\classes\cn\itcast\common\junit\SpringJunitTest.class];
nested exception is java.lang.IllegalArgumentException
这是其中3个错误提示,我总是执着围绕第1个提示找解决方案,花了1天半的时间没任何展。就找第二,第三个问题的
解决方法,结果被我发现了:
Note that the Java 8 bytecode level (-target 1.8, as required by -source 1.8) is only fully supported as of Spring Framework 4.0.
In particular, Spring 3.2 based applications need to be compiled with a maximum of Java 7 as the target,
even if they happen to be deployed onto a Java 8 runtime
jdk1.8与spring 3.2不兼容,吐血。。。。。
然后呢,换不jdk1.7,问题都解决了。想回来真傻啊,视频里的老师带你走捷径,你非要走远路。
写这些是以此为戒,让自己不要总追求最新的,要合适的。