spingboot打jar包

Posted javaddd

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spingboot打jar包相关的知识,希望对你有一定的参考价值。

pom.xml文件中packaging为jar

    <packaging>jar</packaging>  

安装插件

<plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <fork>true</fork>
                    <mainClass>com.ysusoft.nowidwatcher.NowidwatcherApplication</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2-beta-5</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <!--<mainClass>com.bms.Main.Main</mainClass>-->
                            <mainClass>com.ysusoft.nowidwatcher.NowidwatcherApplication</mainClass>
                        </manifest>
                    </archive>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>assemble-all</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

用idea开发工具,点击右侧【maven project】先clean,然后再package,就会把jar包打进target目录中

 技术分享图片

 

以上是关于spingboot打jar包的主要内容,如果未能解决你的问题,请参考以下文章

spingboot一键部署到阿里云(Cloud Toolkit工具)

如何用eclipse打jar包?

Maven项目打Jar包,如何添加依赖

android 简单打jar包

如何用maven将配置文件打在jar包外

spingboot linux 启动方式与脚本