com.sun.org.apache.xml.internal.security.utils does not exist问题的解决

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/edtwar/article/details/79463263

方法一:

网上大神的回答:

自己写的程序是不建议用com.sun这个玩意儿的。。这东西属于“Deprecated and restricted API”。。

而且各种com.sun的包现在都有替代品。。

  如果是公司的老项目非用不可,可以用eclipse导入maven,properties-> Java Compiler -> Errors/Warnings -> Deprecated and restricted API ->
Forbidden reference -> "error" 改成 "warning"

   jdk5是可以用这个api的,jdk6之后就不能用了,只能用java,javax开头的api。(据说而已,莫当真)

方法二(我使用的并通过了):

删除

import com.sun.org.apache.xml.internal.security.utils.Base64;
添加(我使用的):
import org.apache.commons.codec.binary.Base64;

或者用java8 java.util.Base64也行

加密解密(替换):

Base64.encodeBase64String
Base64.decodeBase64
方法三(朋友说有用,我没用过)

<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
					<encoding>utf-8</encoding>
					<!-- added by com.sun.org.apache.xml.internal.security.utils.Base64;编译异常 
						将${java.home}/lib/rt.jar添加到maven的compiler里面 如果 JAVA_HOME 里面没有,将 jre 里面的 copy 
						过来 -->
					<compilerArguments>
						<verbose />
						<bootclasspath>${JAVA_HOME}/jre/lib/rt.jar</bootclasspath>
					</compilerArguments>
				</configuration>
			</plugin>


猜你喜欢

转载自blog.csdn.net/edtwar/article/details/79463263