maven编译时找不到com.sun包.
原因:javac uses a special symbol table that does not include all Sun-proprietary classes. When javac is compiling code it doesn't link against rt.jar by default. Instead it uses special symbol file lib/ct.sym with class stubs.
大意是:javac在编译时,并不引用 rt.jar,用的是一个特别的symbol table(lib/ct.sym),这个symbol table不包含所有的sun包的类;
解决方法:使用 -XDignore.symbol.file,这样javac编译时就会引用rt.jar:
javac -XDignore.symbol.file
maven的pom.xml中增加配置:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>
<arg>-XDignore.symbol.file</arg>
</compilerArgs>
<fork>true</fork>
</configuration>
...
Maven编译找不到com.sun包解决
本文介绍了解决Maven编译过程中遇到的com.sun包缺失问题的方法。通过在pom.xml文件中配置特定参数,使得javac在编译时能够正确引用rt.jar,从而避免了因symbol table不包含所有Sun专有类而导致的问题。
5201





