在Maven项目POM文件错误导入到Eclipse后 [英] Error in pom file in Maven project after importing into Eclipse

查看:700
本文介绍了在Maven项目POM文件错误导入到Eclipse后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我其实新Maven的框架。我已经有一个Maven项目。我安装了Maven插件等进入从 http://m2eclipse.sonatype.org/sites/m2e 我EclipseIDE。然后我输入我的项目,并启用相关性,但该项目正显示出太多的错误。 pom.xml中本身是显示错误。该错误是

 项目生成错误:未知包装:APK
项目生成错误:无法解决的新建扩建:插件
 

等。

我的错误面积为:

 项目的xmlns =htt​​p://maven.apache.org/POM/4.0.0的xmlns:XSI =htt​​p://www.w3.org/2001/XMLSchema -instance
XSI:的schemaLocation =htt​​p://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
< modelVersion> 4.0.0< / modelVersion>

<的groupId> com.nbc.cnbc.android< /的groupId>
< artifactId的> android.domain.tests< / artifactId的>
<版> 1.0.0< /版本>
<包装> APK< /包装>

&所述亲本GT;
    <的groupId> com.nbc.cnbc.android< /的groupId>
    < artifactId的> android.domain.parent< / artifactId的>
    <版> 1.0.0< /版本>
    < relativePath> ../ android.domain.parent / pom.xml的< / relativePath>
< /父>

<名称>&android.domain.tests LT; /名称>
&LT;网址&GT; HTTP://maven.apache.org< / URL&GT;
 

这可能是因为在最后一行指定的URL可以是不同的? 任何想法,为什么这可能发生? 任何答复是高度AP preciated。感谢很多提前!

解决方案

您已经安装了正常的Maven插件,适用于Java项目(和.jar文件)。 对于Android的你所需要的的Maven Android插件

我个人认为,Android的Maven是太麻烦了,我在我的项目中使用的一些相关性,但是这是我如何设置它,当我尝试过了:

  • 设置ANDROID_HOME变量设置为SDK根位置,并添加SDK的工具平台工具文件夹路径(更多信息请参见此链接

  • 启动Eclipse,在你的Andr​​oid项目启用依赖管理。

  • 请确保您有 Maven的中央,以你的存储库,并添加以下到您的POM(更多信息请参见此链接或的this链接)。

 &LT;依赖&GT;
  &LT;的groupId&GT; com.google.android&LT; /的groupId&GT;
  &LT; artifactId的&GT;的android&LT; / artifactId的&GT;
  &LT;版&GT; 2.3.3&LT; /版本&GT;
  &LT;范围&GT;提供与LT; /范围&GT;
&LT; /依赖性&GT;

&LT;建立&GT;
   &LT; sourceDirectory&GT; SRC&LT; / sourceDirectory&GT;
   &LT;插件&GT;
       &LT;插件&GT;
           &LT;的groupId&GT; org.apache.maven.plugins&LT; /的groupId&GT;
           &LT; artifactId的&GT; Maven的编译器插件&LT; / artifactId的&GT;
           &lt;结构&GT;
               &lt;信源&GT; 1.6&LT; /源&GT;
               &lt;目标&GT; 1.6&LT; /目标和GT;
           &LT; /结构&gt;
       &LT; /插件&GT;
       &LT;插件&GT;
           &LT;的groupId&GT; com.jayway.maven.plugins.android.generation2&LT; /的groupId&GT;
           &LT; artifactId的&GT;的maven-的Andr​​oid插件和LT; / artifactId的&GT;
           &lt;结构&GT;
               &LT; SDK&GT;
                  &LT;路径&GT; $ {env.ANDROID_HOME}&LT; /路径&GT;
                   &LT;平台&GT; 10&LT; /平台&GT;
               &LT; / SDK&GT;
               &LT; deleteConflictingFiles&GT;真&LT; / deleteConflictingFiles&GT;
           &LT; /结构&gt;
           &LT;扩展&GT;真&LT; /扩展&GT;
       &LT; /插件&GT;
   &LT; /插件&GT;
&LT; /编译&GT;
 

当然,你可以调整Android版本根据自己的喜好。

I am actually new to the Maven framework. I already have a Maven project. I installed the Maven plugin etc into my EclipseIDE from http://m2eclipse.sonatype.org/sites/m2e. Then I imported my project and enabled dependencies, but the project is showing too many errors. The pom.xml itself is showing errors. The errors are

Project Build Error:unknown packaging:apk
Project Build Error:unresolvable build extension:plugin" 

etc.

My error area is:

project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.nbc.cnbc.android</groupId>
<artifactId>android.domain.tests</artifactId>
<version>1.0.0</version>
<packaging>apk</packaging>

<parent>
    <groupId>com.nbc.cnbc.android</groupId>
    <artifactId>android.domain.parent</artifactId>
    <version>1.0.0</version>
    <relativePath>../android.domain.parent/pom.xml</relativePath>
</parent>

<name>android.domain.tests</name>
<url>http://maven.apache.org</url>

Could it be because the url specified in the last line could be different? Any ideas why this could be happening? Any reply is highly appreciated. Thanks a lot in advance!!

解决方案

You have installed the "normal" Maven plugin that works for Java projects (and .jar files). For Android you need the Maven Android Plugin

Personally, I think that Android Maven is too much of a hassle for the few dependencies that I use in my projects, but this is how I set it up when I tried it out:

  • Set the ANDROID_HOME variable to your SDK root location and add the SDK's tools and platform-tools folders to your path (more info see this link)

  • Start Eclipse and enable "Dependency management" on your Android project.

  • Make sure you include Maven Central to you repositories and add the following to your pom (more info see this link or this link).

<dependency>
  <groupId>com.google.android</groupId>
  <artifactId>android</artifactId>
  <version>2.3.3</version>
  <scope>provided</scope>
</dependency>

<build>
   <sourceDirectory>src</sourceDirectory>
   <plugins>
       <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
           <configuration>
               <source>1.6</source>
               <target>1.6</target>
           </configuration>
       </plugin>
       <plugin>
           <groupId>com.jayway.maven.plugins.android.generation2</groupId>
           <artifactId>maven-android-plugin</artifactId>
           <configuration>
               <sdk>
                  <path>${env.ANDROID_HOME}</path>
                   <platform>10</platform>
               </sdk>
               <deleteConflictingFiles>true</deleteConflictingFiles>
           </configuration>
           <extensions>true</extensions>
       </plugin>
   </plugins>
</build>

Off course you can adjust the android version to your liking.

这篇关于在Maven项目POM文件错误导入到Eclipse后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆