簡體   English   中英

Visual Studio Code maven 項目 - 如何添加源文件夾

[英]Visual Studio Code maven project - how to add a source folder

我正在嘗試將我們的 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>

在這個位於屏幕左下方的菜單中,打開 Maven,找到您正在處理的項目。

在這個位於屏幕左下方的菜單中,打開 Maven,找到您正在處理的項目,然后右鍵單擊。 您將看到一個顯示自定義的選項。 選擇那個。 然后在頂部顯示的命令面板中輸入:“generate-source”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM