Maven can't compile class which depends on rt.jar

前端 未结 2 1849
眼角桃花
眼角桃花 2021-02-19 02:32

CI-server (Hudson), for which I am responsible, builds Maven project. After the last commit, the build failed:

[INFO] -------------------------------------------         


        
相关标签:
2条回答
  • The missing class seems to be JRE internal (as indicated in its namespace), and should not be referenced from your code. It is probably only available on specific platforms or JRE versions.

    Consider replacing it with another Base64 encoder class, e.g. one from the Apache Commmons Codec project.

    Java 8 update

    Java 8 finally introduced a Base64 class in the public part of the JDK: java.util.Base64.

    0 讨论(0)
  • 2021-02-19 02:54

    Need to specify -XDignore.symbol.file and add rt.jar dependency and <fork>true</fork> as the compiler plugin will otherwise silently drop any -XD flags: e.g.

        ...
        <dependency>
            <groupId>groupid</groupId>
            <artifactId>artifiactId</artifactId>
            <version>1.0</version>
            <scope>system</scope>
            <systemPath>${java.home}/lib/rt.jar</systemPath>
        </dependency>
    </dependencies>
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <compilerArgs>
                        <arg>-XDignore.symbol.file</arg>
                    </compilerArgs>
                    <fork>true</fork>
                </configuration>
                ...
    
    0 讨论(0)
提交回复
热议问题