异常: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project cas: Compilation failure: Compilation failure
背景:公司项目使用的cas单点登录,被第三方检测出账号密码明文传输,存在被捕获的风险
引入AES以后maven编译报错:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project cas: Compilation failure: Compilation failure:
[ERROR] /D:/project/edu_sso/src/main/java/org/jasig/cas/util/AesUtils.java:[5,20] 程序包javax.crypto不存在
[ERROR] /D:/project/edu_sso/src/main/java/org/jasig/cas/util/AesUtils.java:[6,25] 程序包javax.crypto.spec不存在
[ERROR] /D:/project/edu_sso/src/main/java/org/jasig/cas/util/AesUtils.java:[7,25] 程序包javax.crypto.spec不存在
提示找不到javax.crypto.* ,这个包是jre里面的,故找到maven-compiler-plugin,加入jce.jar
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<compilerArguments>
<bootclasspath>${JAVA_HOME}/jre/lib/rt.jar;${JAVA_HOME}/jre/lib/jce.jar</bootclasspath>
</compilerArguments>
<showWarnings>true</showWarnings>
<encoding>utf8</encoding>
</configuration>
</plugin>
本地编译没问题了,拿到linux上报错,还是找不到,发现由于linux和windows分隔符是不一样的,故次数要用${path.separator}
<bootclasspath>${JAVA_HOME}/jre/lib/rt.jar${path.separator}${JAVA_HOME}/jre/lib/jce.jar</bootclasspath>
至此,问题解决~