English 中文(简体)
Maven 生成源文件夹未被 Eclipse 接收
原标题:Maven generate-sources folder not being picked up by Eclipse

我正准备将我的建筑从Ant迁移到Maven。 Ant建筑用来编译“ 代码生成器 ”, 执行这个“ 代码生成器 ”, 生成了一套 Java 和 C 代码 。 然后,它将生成的 Java 代码与一些额外的代码一起编译出来, 产生一个罐子 。

我很容易在马文复制这个, 当我从指挥线上跑出来的时候效果很好, 但是日圆在抱怨,

Failure to find {group.id}:{artifact.id}:pom:1.0.0-SNAPSHOT in http://{our internal site repository}/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of snapshots has elapsed or updates are forced

其中的群組. id 和 article. id 是群組與藝術品 ID 我的代碼產生器插件

以及任何引用生成代码的代码也未能编译 。

我的玛文建筑包括

  • 一个发电机项目,它只包含代码生成器的 Java 代码。

  • 发电机插件工程, 它只包含将发电机包装为 Maven 插件的代码。 这取决于发电机工程 。

  • 使用插件生成代码的 xyz 工程。 代码最终会出现在此工程的目标/ 源代码/ xxx 文件夹中 。 我已经根据 < a href=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

如果我手动将生成的源文件夹添加到剪贴板构建路径中, 所有与代码相关的错误都会在该项目上消失, 但没有在任何下游项目上消失, 上面列出的错误“ 找不到... ” 。

令我感到迷惑的是,它指的是:pom:1.0.0-SNAPSHOT,而实际上我的发电机插座被定义为maven插座。

这是明智的做法吗?

为什么我得到一个"找不到..."错误?

为什么伊利普斯不接收我生成的源文件夹?

我还得说,我在我的日光灯IDE中安装了 m2e 插件和 建筑-help-maven-plutin 的 m2e 连接器。

问题回答

似乎在从仓库下载 lib 时有问题。 我曾经收到过相同的错误信息 。

  • 你看过你的本地仓库吗?

    转到.m2 文件夹, 并查找 < code>/ nexus/ content/ groups/ public 。 如果文件夹存在, 请打开它, 看看 lib 下载是否正确 。 如果没有, 请尝试删除文件夹, 并尝试运行 < code> mvn 安装 , 强制下载 lib 下载 。

    在Eclipse,运行 right button & gt; Maven & gt; 更新工程

  • 您是否使用像 艺术一样的本地仓库? 您是否使用? 还在 < code> repo1-cache (或类似) 文件夹中查找 lib 。 请查看 jar 是否存在 。

  • 你背后有防火墙或代理人吗?

使用月食 Indigo3.7, 这正是我发现使用弹簧3.1.1 效果不错的。 弹簧3.1.1 也有3. 0.6 版本。 一旦我安装插件, 并放入 pom 的正确区域, 并包括将 java 源放入目标/ 源源/ cxf 文件夹的 rgline 和 countdirs, 然后 Maven 生成了源 。

....

 <properties>...

   <dependencyManagement>
      <dependencies>.....
   </dependencyManagement>

<dependencies>
   <dependency>....

</dependencies>



<!-- *************************** Build process ************************************* -->
<build>
    <finalName>projName</finalName>
    <plugins>
        <!-- Force Java 6 -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <!-- Deployent on AS from console
        <plugin>
            <groupId>org.jboss.as.plugins</groupId>
            <artifactId>jboss-as-maven-plugin</artifactId>
            <version>${version.jboss.as.maven.plugin}</version>
        </plugin>
        -->

        <!-- wildbill added tomcat plugin -->
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.0</version>              
        </plugin>

        <!-- Surefire plugin before 2.9 version is buggy. No need to declare here,
              it s being referenced below w/ the version
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12</version>
        </plugin>
        -->

        <!-- developer added these -->   
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <compilerArguments>
                    <endorseddirs>target/generated-sources/cxf</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12</version>
            <configuration>
                <forkMode>once</forkMode>
                <argLine>-Djava.endorsed.dirs=target/generated-sources/cxf</argLine>
            </configuration>
        </plugin>           
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <compilerArguments>
                    <endorseddirs>target/generated-sources/cxf</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <forkMode>once</forkMode>
                <argLine>-Djava.endorsed.dirs=target/generated-sources/cxf</argLine>
            </configuration>
        </plugin>                       
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>                       
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>javax.xml.bind</groupId>
                        <artifactId>jaxb-api</artifactId>
                        <version>2.2</version>
                    </artifactItem>
                    <artifactItem>
                        <groupId>javax.xml.ws</groupId>
                        <artifactId>jaxws-api</artifactId>
                        <version>2.2</version>
                    </artifactItem>
                </artifactItems>
                <outputDirectory>target/generated-sources/cxf</outputDirectory>
            </configuration>                      
        </plugin>                                                 
    </plugins>
</build>



<!-- *********************** Profiles ************************************ -->
<profiles>
    <profile>
        <!-- When built in OpenShift the  openshift  profile will be 
            used when invoking mvn. -->
        <!-- Use this profile for any OpenShift specific customization 
            your app will need. -->
        <!-- By default that is to put the resulting archive into the 
             deployments  folder. -->
        <!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
        <id>projName</id>
        <build>
            <plugins>                                                   
                <plugin>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-codegen-plugin</artifactId>
                    <version>2.5.2</version>                        
                    <executions>
                        <execution>
                            <id>process-sources</id>
                            <phase>generate-sources</phase>                                                                                               
                            <configuration>
                                <fork>once</fork>
                                <additionalJvmArgs>-Djava.endorsed.dirs=target/generated-sources/cxf</additionalJvmArgs>                                          
                            </configuration>
                            <goals>                             
                                <goal>wsdl2java</goal>
                            </goals>
                        </execution>
                    </executions>                       
                    <dependencies>
                        <dependency>
                           <groupId>com.sun.xml.bind</groupId>
                           <artifactId>jaxb-impl</artifactId>
                           <version>2.2</version>
                        </dependency>
                        <dependency>
                           <groupId>com.sun.xml.bind</groupId>
                           <artifactId>jaxb-xjc</artifactId>
                           <version>2.2</version>
                        </dependency>
                     </dependencies>
                </plugin>

                <!-- Actual war created in default target dir -->
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                                                     <version>2.2</version>                                               
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

如果您的 wsdl 文件夹在 ${ basir}/src/main/ resources 中, 它会自动找到它

希望这有帮助!





相关问题
In Eclipse, why doesn t "Show In" appear for non-Java files?

If I have a *java file open, I can right click on the source, scroll down to "Show In (Alt-Shift-W)", and select Navigator. If I have an *xml, *jsp, or pretty much anything besides a Java source ...

Eclipse: Hover broken in debug perspective

Since upgrading Eclipse (Galileo build 20090920-1017), hover in debug no longer displays a variable s value. Instead, hover behaves as if I were in normal Java perspective: alt text http://...

Eclipse smart quotes - like in Textmate

Happy Friday — Does anyone know if eclipse has the notion of smart quotes like Textmate. The way it works is to select some words and quote them by simply hitting the " key? I m a newbie here so be ...

Indentation guide for the eclipse editor

Is there a setting or plugin for eclipse that can show indentation guides in the editor? Something like the Codekana plugin for visual studio (not so fancy is also OK). Important that it works with ...

Adding jar from Eclipse plugin runtime tab

I want to add .jar files for plugin from the Runtime tab of manifest file. When I use the Add... button, I can see only sub-directories of the plugin project. So if I want to add same .jar file to ...

How to copy multiple projects into single folder in eclipse

I have two projects, Project1 and Project2. Now i want to copy this projects into eclipse workspace but i want these projects to be in a single folder like below. Eclipse Workspace -> Project -> ...

Java: Finding out what is using all the memory

I have a java application that runs out of memory, but I have no idea which code is allocating the memory. Is there an application with which I can check this? I use Eclipse.

热门标签