java项目上出现红色感叹号

jar包导入不对。删除掉错误的即带红叉的jar包在重新导入新的jar包即可。注意程序需要的版本

黄色叹号表示声明但在程序中没有用到。

import Test时报错

错误信息为:Access restriction: The type 'Test' is not API (restriction on required library 'C:\software\eclipse\eclipse\plugins\org.junit_4.12.0.v201504281640\junit.jar')

此时应修改access rules,在项目的build path configuration中创建junit的access规则

java项目上出现红色感叹号_第1张图片

选中edit创建如下图规则

java项目上出现红色感叹号_第2张图片

之前的报错消失了

java项目上出现红色感叹号_第3张图片java项目上出现红色感叹号_第4张图片

你可能感兴趣的:(java项目上出现红色感叹号)