首先删除:
import java.util.Base64;
然后导入
import org.apache.commons.codec.binary.Base64;
如果报错没有这个包,就在pom.xml中加入依赖
基于Maven的话加入依赖:
<!--https://mvnrepository.com/artifact/org.apache.directory.studio/org.apache.commons.codec -->
<dependency>
<groupId>org.apache.directory.studio</groupId>
<artifactId>org.apache.commons.codec</artifactId>
<version>1.8</version>
</dependency>
基于Gradle的话:
// https://mvnrepository.com/artifact/org.apache.directory.studio/org.apache.commons.codec
compile group: 'org.apache.directory.studio', name: 'org.apache.commons.codec', version: '1.8'
解决!