VsCode 开发 java项目 把resources识成包 或者识别成普通文件夹解决办法

如果在 idea 中的话,右键文件夹转换成resource文件夹就行了,但是 vscode中是没有这个功能的

1.打开项目目录
VsCode 开发 java项目 把resources识成包 或者识别成普通文件夹解决办法_第1张图片
2. 找到 .classpath 文件 用记事本打开
VsCode 开发 java项目 把resources识成包 或者识别成普通文件夹解决办法_第2张图片
3. 在顶部加入代码

	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
		<attributes>
			<attribute name="maven.pomderived" value="true"/>
		attributes>
	classpathentry>

VsCode 开发 java项目 把resources识成包 或者识别成普通文件夹解决办法_第3张图片

下面是项目中完整的文件实例


<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="src" path="target/generated-sources/annotations">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="ignore_optional_problems" value="true"/>
			<attribute name="m2e-apt" value="true"/>
		attributes>
	classpathentry>
	<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
		<attributes>
			<attribute name="optional" value="true"/>
			<attribute name="maven.pomderived" value="true"/>
			<attribute name="ignore_optional_problems" value="true"/>
			<attribute name="m2e-apt" value="true"/>
			<attribute name="test" value="true"/>
		attributes>
	classpathentry>
	<classpathentry kind="output" path="target/classes"/>
classpath>

你可能感兴趣的:(vscode,java)