Access restriction: The method XXX from the type XXX is not accessible due to restriction XXX

插件重构的时候 遇到这个问题

Access restriction: The method setDefaultAutoCommit(boolean) from the type BasicDataSource is not accessible due to restriction on required library com.XXX.ro.studio.debug/lib/commons-dbcp-1.2.1.jar

开始以为是插件包之间依赖问题,但是查看一下却没有问题。

后来发现是eclipse本身设置的问题

它默认把这些受访问限制的API设成了ERROR,只要把Windows-Preferences-Java-Complicer-Errors/Warnings


里面的Deprecated and restricted API中的Forbidden references(access rules)选为Warning就可以编译通过了。

原文地址:https://www.cnblogs.com/snake-hand/p/3212301.html