添加到maven的依赖包装为mar

时间:2012-03-07 10:24:36

标签: maven axis2

我有一个项目,它使用了来自axis2项目的几个依赖项。其中一个如果是梅克斯(metada exchange)。

mex的最新版本打包为mar文件。如果我尝试将此依赖项添加到我的项目中maven将失败:

    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>mex</artifactId>
        <version>1.6.1</version>
        <packaging>mar</packaging>

    </dependency>

org.apache.maven.reactor.MavenExecutionException: Parse error reading POM. Reason: Unrecognised tag: 'packaging' (position: START_TAG seen ...</version>\n\t\t\t<packaging>... @229:15)  for project unknown at /project/pom.xml
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:404)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:272)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.project.InvalidProjectModelException: Parse error reading POM. Reason: Unrecognised tag: 'packaging' (position: START_TAG seen ...</version>\n\t\t\t<packaging>... @229:15)  for project unknown at /project/pom.xml
at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1610)
at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1571)
at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:506)
at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:604)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:487)
at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:391)
... 12 more
Caused by: org.codehaus.plexus.util.xml.pull.XmlPullParserException: Unrecognised tag: 'packaging' (position: START_TAG seen ...</version>\n\t\t\t<packaging>... @229:15) 
at org.apache.maven.model.io.xpp3.MavenXpp3Reader.parseDependency(MavenXpp3Reader.java:1225)
at org.apache.maven.model.io.xpp3.MavenXpp3Reader.parseModel(MavenXpp3Reader.java:2095)
at org.apache.maven.model.io.xpp3.MavenXpp3Reader.read(MavenXpp3Reader.java:3913)
at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1606)
... 18 more

我尝试添加mar插件,但它没有帮助

<plugin>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-mar-maven-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
                <includeDependencies>false</includeDependencies>
            </configuration>
        </plugin>

1 个答案:

答案 0 :(得分:4)

看起来您没有正确阅读错误消息,因为它说:

Parse error reading POM. Reason: Unrecognised tag: 'packaging' (position: START_TAG seen ...</version>\n\t\t\t<packaging>... @229:15)  for project unknown at /project/pom.xml

这意味着您必须使用:

<dependency>
   <groupId>org.apache.axis2</groupId>
   <artifactId>mex</artifactId>
   <version>1.6.1</version>
   <type>mar</type>
</dependency>

代替。

更新:问题是这些mar工件被打包为jar。所以你必须采取以下方式:

<dependency>
   <groupId>org.apache.axis2</groupId>
   <artifactId>mex</artifactId>
   <version>1.6.1</version>
</dependency>