Maven中创建可执行的JAR文件,在清单缺少主级

问题描述 投票:0回答:1

这是我的pom.xml我怎样才能使一个可执行的JAR,我在谷歌阅读,它需要有主类中的MANIFEST.MF。我试着用addind插件,但没有enter image description here -

 <?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>Sims_for_Import</artifactId>
               <version>1.0-SNAPSHOT</version>
               <packaging>jar</packaging>
               <properties>
                   <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                   <maven.compiler.source>1.8</maven.compiler.source>
                   <maven.compiler.target>1.8</maven.compiler.target>
               </properties>
               <dependencies>
             <dependency>
             <groupId>com.oracle</groupId>
             <artifactId>ojdbc6</artifactId>
             <version>11.2.0.3</version>
               <!--<scope>system</scope>-->
               <!--<systemPath>${basedir}/ojdbc6-11.2.0.3.jar</systemPath>-->
           </dependency>
            <dependency>
                  <groupId>com.microsoft.sqlserver</groupId>
             <artifactId>sqljdbc42</artifactId>
             <version>4.2</version>
            </dependency>
               </dependencies>
               <name>Sims_for_Import</name>
           </project>
java swing manifest.mf
1个回答
1
投票

你应该利用maven-jar-plugin来包装你的jar文件,并提供一个主类:

<build>
    <plugins>
        <!-- ... other plugins ... -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.1.1</version>
            <configuration>
                <archive>
                    <manifest>
                        <!-- Your main class -->
                        <mainClass>sims_for_import.Main</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

你可以看到在maven central repository最新可用的插件版本上市。

© www.soinside.com 2019 - 2024. All rights reserved.