zoukankan      html  css  js  c++  java
  • maven打可执行jar包

    使用场景:我们用maven打的jar包,是可以通过java -jar执行的,但是不是spring的项目,所以需要自己配置maven来满足使用需要.通过以下配置就可以解决错误信息.

      <build>
            <!--<finalName>ocrtest</finalName>-->
    
            <plugins>
              <!--  <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>App</mainClass> &lt;!&ndash; 此处为主入口&ndash;&gt;
                        </manifest>
                    </archive>
                </configuration>
                </plugin>-->
    
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                    <configuration>
                        <source>8</source>
                        <target>8</target>
                        <encoding>UTF-8</encoding>
                        <verbose>true</verbose>
                        <showWarnings>true</showWarnings>
                    </configuration>
                </plugin>
    
    
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <archive>
                            <manifest>
                                <mainClass>App</mainClass>
                            </manifest>
                        </archive>
                        <archiverConfig>
                            <encoding>utf-8</encoding>
                        </archiverConfig>
                    </configuration>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    <build>
    <!--<finalName>ocrtest</finalName>-->

    <plugins>
    <!-- <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.2.0</version>
    <configuration>
    <archive>
    <manifest>
    <addClasspath>true</addClasspath>
    <mainClass>App</mainClass> &lt;!&ndash; 此处为主入口&ndash;&gt;
    </manifest>
    </archive>
    </configuration>
    </plugin>-->


    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.1</version>
    <configuration>
    <source>8</source>
    <target>8</target>
    <encoding>UTF-8</encoding>
    <verbose>true</verbose>
    <showWarnings>true</showWarnings>
    </configuration>
    </plugin>


    <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
    <descriptorRefs>
    <descriptorRef>jar-with-dependencies</descriptorRef>
    </descriptorRefs>
    <archive>
    <manifest>
    <mainClass>App</mainClass>
    </manifest>
    </archive>
    <archiverConfig>
    <encoding>utf-8</encoding>
    </archiverConfig>
    </configuration>
    <executions>
    <execution>
    <id>make-assembly</id>
    <phase>package</phase>
    <goals>
    <goal>single</goal>
    </goals>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>
  • 相关阅读:
    Binary Tree Maximum Path Sum
    ZigZag Conversion
    Longest Common Prefix
    Reverse Linked List II
    Populating Next Right Pointers in Each Node
    Populating Next Right Pointers in Each Node II
    Rotate List
    Path Sum II
    [Leetcode]-- Gray Code
    Subsets II
  • 原文地址:https://www.cnblogs.com/zhulibin2012/p/13948342.html
Copyright © 2011-2022 走看看