首页 > 解决方案 > Visual Studio Code maven 项目 - 如何添加源文件夹

问题描述

我正在尝试将我们的 Maven Java 项目从 Eclipse 迁移到 Visual Studio。

我们的 Maven 项目在 src/main/generated 文件夹中有一个生成的源文件夹(用于我们的肥皂服务模式类)(在 POM 中有适当的 build-helper-maven-plugin 配置)

在eclipse中,我可以手动右键单击模块并“添加源文件夹”来告诉eclipse该文件夹。

我似乎无法在 VSCode 的 maven 插件中找到这样的选项,这会导致数百个“无法解析导入 xxx”错误

我该如何解决这个问题?我们正被迫离开 Eclipse 并进入 Visual Studio,但目前我不能这样做,直到我能解决这个问题。

如果有帮助,这里是相关的 POM 配置:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
                <execution>
                    <id>add-source</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src/main/generated</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        ...
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.apache.cxf</groupId>
                                    <artifactId>cxf-codegen-plugin</artifactId>
                                    <versionRange>[2.4.0,)</versionRange>
                                    <goals>
                                        <goal>wsdl2java</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute>
                                        <runOnIncremental>false</runOnIncremental>
                                    </execute>
                                </action>
                            </pluginExecution>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.codehaus.mojo</groupId>
                                    <artifactId>build-helper-maven-plugin</artifactId>
                                    <versionRange>[1.7,)</versionRange>
                                    <goals>
                                        <goal>add-source</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute></execute>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>

标签: javamavenvisual-studio-code

解决方案


推荐阅读