Maven配置maven-eclipse-plugin(mvn eclipse:eclipse报错问题)

来源:互联网 发布:c语言不输出无意义的0 编辑:程序博客网 时间:2024/06/13 09:31

今天遇到这种情况,刚从github上面down到本地的代码导入eclipse时的问题:
该项目在github上根据项目结构看出是使用maven构建的,但无法导入到eclipse,所以使用maven将其整理,执行mvn eclipse:eclipse,
执行后出现以下问题:
根据错误原因得知,需要在该项目的pom.xml配置maven-eclipse-plugin这个插件,在网上查找资料后,找到解决办法,如下:

1.在pom.xml添加maven-eclipse-plugin的配置

<plugin>   <groupId>org.apache.maven.plugins</groupId>   <artifactId>maven-eclipse-plugin</artifactId>   <configuration>    <additionalConfig>     <file>      <name>.project</name>      <location>src/main/project/project.xml</location>     </file>    </additionalConfig>   </configuration>  </plugin> 

该插件需要为其准备单独的配置文件project.xml,

2.project.xml配置文件

<?xml version="1.0" encoding="UTF-8"?><projectDescription> <name>storm-starter</name> <comment></comment> <projects> </projects> <buildSpec>  <buildCommand>   <name>org.eclipse.jdt.core.javabuilder</name>   <arguments>   </arguments>  </buildCommand>  <buildCommand>   <name>org.maven.ide.eclipse.maven2Builder</name>   <arguments>   </arguments>  </buildCommand> </buildSpec> <natures>  <nature>org.eclipse.jdt.core.javanature</nature>  <nature>org.maven.ide.eclipse.maven2Nature</nature> </natures></projectDescription>


将该文件放置于该项目的src/main/project/project.xml目录下(注意与上面pom.xml中的配置一致);

3.执行mvn eclipse:eclipse

上述配置完毕后重新执行mvn eclipse:eclipse,如图:

4.导入eclipse

执行完命令后,在此打开eclipse,重新导入该项目,顺利导入!

参考资料:

http://maven.apache.org/plugins/maven-eclipse-plugin/eclipse-mojo.html



0 0