閱讀241 返回首頁    go 阿裏雲 go 技術社區[雲棲]


Spring tool suite編譯不通過:Access restriction: The type XXX is not accessible

一、發現問題

通過jaxb操作xml,引入javax.xml.bind相關包時,spring tool suite編譯不通過。

 

二、分析原因

Spring tool suite就是eclipse上套了一層spring的插件,本質還是eclipse。Eclipse默認把某些受訪問限製的API設成了ERROR。,所以會編譯不通過。


三、解決問題

方法1:

把對某些限製API的級別設置為warning

Windows -> Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and trstricted API -> Forbidden reference (access rules): -> change to warning。

方法2:

在project build path中先移除JRE System Library,再添加庫JRE System Library,重新編譯後就一切正常。

方法3:

工程上右鍵->工程屬性->ja。va builder path->Libraries標簽,點擊JRE System Library裏麵的Access rules,add sun/** 為accessible,如果該項存在,就edit。

方法4:

Windows -> Preferences -> Java -> Installed JREs -> 選擇用的JDK -> Edit -> Add External JARs。


四、總結

我實驗了前兩種方法,可以實現。還有一些方法是參照網上的,請大家自己試一試。

 

參考地址:https://blog.sina.com.cn/s/blog_6714fba70100x6mz.html


最後更新:2017-04-03 16:49:07

  上一篇:go tomcat中jsp引用圖片img的src屬性帶中文路徑無法顯示的解決
  下一篇:go 發送郵件程序報錯454 Authentication failed以及POP3和SMTP簡介