1、打开限制:

比如我们代码中使用sun.misc. BASE64Encoder /BASE64Decoder类默认会报错,因为它们不属于JDK标准库范畴;在JDK中包含了该类,可以使用单需要设置。

在eclipse中直接使用却找不到该类,解决方法如图:

eclipse中访问受限api_eclipse


2、eclipse中Access restriction问题的解决:

如果在Eclipse使用某些访问受限的API时,会报这种错误:
Access restriction: The type Resource is not accessible due to restriction on required library
这是因为Eclipse默认把这些受访问限制的API设成了ERROR,在java-compiler-Errors/Warnings选项里面的Deprecated and restricted API中的Forbidden references(access rules)选为Warning就可以编译通过,只是报警告而不是报错,保证了编译能通过。

​https://www.iteye.com/blog/paddy-w-1852963​

3、The import javax.validation cannot be resolved:

在做业务开发时,经常要对参数进行校验,如下

if (StringUtils.isBlank(request.getA())) {
throw new IllegalArgumentException("A is blank");
}

这时我们可以使用@NotNull这类的注解,如果直接使用会提示The import javax.validation cannot be resolved 是因为我们在pom.xml文件中忘记写入相应的依赖:

<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<!-- <version>2.1.0.Final</version> -->
</dependency>

改依赖在hibernate中也被使用,所以也可以直接引入hibernate对应的库。