• 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>
  • 相关阅读:
    我拒绝接受的几个最佳编程实践方法
    女人千万别写代码
    Visual Studio原生开发的10个调试技巧(二)
    20个很有用的PHP类库
    8个开发必备的PHP功能
    青少年如何使用 Python 开始游戏开发
    rmdir 删除空目录
    rm 删除文件或目录
    mv 移动或重命名文件
    cp 复制文件或目录
  • 原文地址:https://www.cnblogs.com/zhulibin2012/p/13948342.html
Copyright © 2020-2023  润新知