最近看nacos spring boot 代码时候,其带的example 在eclipse跑不起来,没有run as java application,处理过程记录如下。
首先是增加java nature,如下图
增加完后还需要手工增加.classpath 到项目根目录下,内容如下:
?xml version="1.0" encoding="UTF-8"?classpathclasspathentrykind="src"output="target/classes"path="src/main/java"attributesattributename="optional"value="true"/attributename="maven.pomderived"value="true"//attributes/classpathentryclasspathentryexcluding="**"kind="src"output="target/classes"path="src/main/resources"attributesattributename="maven.pomderived"value="true"//attributes/classpathentryclasspathentrykind="src"output="target/test-classes"path="src/test/java"attributesattributename="optional"value="true"/attributename="maven.pomderived"value="true"/attributename="test"value="true"//attributes/classpathentryclasspathentrykind="con"path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"attributesattributename="maven.pomderived"value="true"//attributes/classpathentryclasspathentrykind="con"path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"attributesattributename="maven.pomderived"value="true"//attributes/classpathentryclasspathentrykind="output"path="target/classes"//classpath
然后close/open 项目,最后要检查resources内容是否输出到target/classes下,如果没有需要从界面delete后重新设置下build path。