eclipse中的快速修复的另类用法(转,例子)

今天在学习junit4测试的时实现例子的时候,当我在java build path加入junit4的包之后,eclipse显示了一个warning,

Classpath entry org.eclipse.jdt.junit.JUNIT_CONTAINER/4 will not be exported or published. Runtime ClassNotFoundExceptions may result. 

于是我在网上百度了之后发现,一个回答,和我遇到的问题类似,但是不完全相同,她所使用的方法是eclipse的快速修复,非常另类,我试着用这个方法解决了我的问题,虽然不明白是什么原理,但是我觉得这种另类的快速修复的方法值得学习.

Classpath entry org.eclipse.jdt.USER_LIBRARY/hibernate lib will not be exported or published.Runtime ClassNotFoundExceptions may result.

1、启用Maven Dependency后,提示上面的警告。

解决方法是:打开Problem视图,选中此警告,然后按Ctrl+1或者右击选择fix it,弹出修复对话框,选择 "Exclude the associated raw classpath entry....”

这个操作好像是添加了下面这个attribute到 .classpath:

<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>

2、还一种是我把字符集改成UTF-8后,这个提示就直接没了,不知道跟字符集是否有关

注意第一种快速修复的方法,虽然我已经会了在编写代码的时候用到快速修复,但是这种方法也必须学会,很有用的!
原文地址:https://www.cnblogs.com/com-wushuang/p/5359418.html