问题:pom文件已经有指定source,target,但1.8编译后无法用1.6或1.7运行。
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin>
解决方案:
根据报错的代码定位,用到了wsimport, 经过查找(https://docs.oracle.com/javase/8/docs/technotes/tools/windows/wsimport.html)发现有个参数-Xnocompile(Does not compile the generated Java files.),故在pom中相应位置加入以下代码。
<xnocompile>true</xnocompile>
javap 是JDK自带的反汇编器,可以查看java编译器为我们生成的字节码
-v -verbose Print additional information
-cp <path> Specify where to find user class files
运行 javap -v -cp <> <>后可以看到
minor version: 0
major version: 50
得以验证改动有效