this compilation unit is not on the build path of a java project

时间:2023-03-09 18:01:02
this compilation unit is not on the build path of a java project

在eclipse中新建maven project后,会自动生成main\test目录结构,新建一个测试类,然后编辑类文件时,总是提示错误:this compilation unit is not on the build path of a java project。后来在网上找到了解决办法:

  1. 需要先安装maven eclipse插件 m2eclipse
  2. 执行命令 mvn eclipse:clean
  3. 执行命令 mvn eclipse:eclipse

以上操作成功后,问题就解决了!