您的位置 首页 java

Eclipse 没有run as java application

最近看nacos spring boot 代码时候,其带的example 在 eclipse 跑不起来,没有run as java application,处理过程记录如下。

首先是增加java nature,如下图

Eclipse 没有run as java application


增加完后还需要手工增加. classpath 到项目根目录下,内容如下:

 <?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" output="target/classes" path="src/main/java">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name=" maven .pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="test" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		</attributes>
	</classpathentry>
	<classpathentry kind="output" path="target/classes"/>
</classpath>
  

然后 close / open 项目,最后要检查resources内容是否输出到target/classes下,如果没有需要从界面delete后重新设置下build path。

文章来源:智云一二三科技

文章标题:Eclipse 没有run as java application

文章地址:https://www.zhihuclub.com/200515.shtml

关于作者: 智云科技

热门文章

网站地图