我无法在pom.xml中添加插件,我需要创建一个maven项目的可执行jar

时间:2017-03-05 05:20:44

标签: maven maven-plugin

我无法在pom.xml文件中添加插件。帮我解决问题。 我需要这个插件来制作项目的jar文件。插件标签显示错误。我试过这些链接但无法解决它:http://wiki.netbeans.org/QuickStartJavaMavenProject  

 <?xml version="1.0" encoding="UTF-8"?>
    <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.mycompany</groupId>
        <artifactId>Restful_java_swing_M</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>



        <name>Restful_java_swing_M</name>


        <repositories>
            <repository>
                <id>unknown-jars-temp-repo</id>
                <name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
                <url>file:${project.basedir}/lib</url>
            </repository>
        </repositories>
        <properties>
            <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <springframework.version>4.3.0.RELEASE</springframework.version>
            <mysql.connector.version>5.1.31</mysql.connector.version>
            <jackson.library>2.7.5</jackson.library>        
            <hibernate.version>4.3.11.Final</hibernate.version>
        </properties>

        <dependencies>
            <dependency>
                <groupId>unknown.binary</groupId>
                <artifactId>AbsoluteLayout</artifactId>
                <version>SNAPSHOT</version>
            </dependency>
            <dependency>


        </dependencies>





<p>the plugin tag shows error. </p>


    <plugins>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>2.4</version>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <archive>
                            <manifest>

                                <mainClass>mainJFrame</mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <phase>package</phase>
                            <goals>                        
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>

        </project>

2 个答案:

答案 0 :(得分:1)

来自Maven Plugins

的文档
  

有构建和报告插件:

     

构建插件 将在构建期间执行,它们应该是   在POM的<build/>元素中配置。

     

报告插件   将在网站生成期间执行,它们应该是   在POM的<reporting/>元素中配置。因为   报告插件的结果是生成的网站Reporting的一部分   插件应该是国际化的和本地化的。你可以阅读   更多关于我们的插件的本地化以及如何提供帮助。

因此,对于您的情况,您需要确保插件在构建元素下定义为 -

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            ... other details 
        </plugin>
        ... other plugins
    </plugins>
</build>

答案 1 :(得分:0)

哦,我解决了这个问题。插件标签没有显示错误bcoz我把一个构建标签放在插件标签上。

相关问题