Maven pom.xml 必须包含

  1. <packaging>jar</packaging>
  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.springframework.boot</groupId>
  5. <artifactId>spring-boot-maven-plugin</artifactId>
  6. <configuration>
  7. <fork>true</fork>
  8. </configuration>
  9. </plugin>
  10. </plugins>
  11. </build>

完整pox.xml

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  3. <modelVersion>4.0.0</modelVersion>
  4. <groupId>com.feedback</groupId>
  5. <artifactId>feedback-service</artifactId>
  6. <version>0.1.0</version>
  7. <packaging>jar</packaging>
  8. <properties>
  9. <java.version>1.8</java.version>
  10. </properties>
  11. <parent>
  12. <groupId>org.springframework.boot</groupId>
  13. <artifactId>spring-boot-starter-parent</artifactId>
  14. <version>1.3.0.RELEASE</version>
  15. </parent>
  16. <dependencies>
  17. <!-- spring boot -->
  18. <dependency>
  19. <groupId>org.springframework.boot</groupId>
  20. <artifactId>spring-boot-starter-web</artifactId>
  21. </dependency>
  22. <dependency>
  23. <groupId>org.springframework.boot</groupId>
  24. <artifactId>spring-boot-starter-data-jpa</artifactId>
  25. </dependency>
  26. <!-- mysql数据库 -->
  27. <dependency>
  28. <groupId>mysql</groupId>
  29. <artifactId>mysql-connector-java</artifactId>
  30. </dependency>
  31. <!-- commons-lang -->
  32. <dependency>
  33. <groupId>commons-lang</groupId>
  34. <artifactId>commons-lang</artifactId>
  35. <version>2.6</version>
  36. </dependency>
  37. </dependencies>
  38. <!-- jar -->
  39. <build>
  40. <plugins>
  41. <plugin>
  42. <groupId>org.springframework.boot</groupId>
  43. <artifactId>spring-boot-maven-plugin</artifactId>
  44. <configuration>
  45. <fork>true</fork>
  46. </configuration>
  47. </plugin>
  48. </plugins>
  49. </build>
  50. </project>

进入到项目目录下运行:mvn clean package

会在项目目录下target文件夹中生成jar

如上生成的jar文件在:D:\programmer\eclipse\feedback-service\target  文件夹中

java -jar 运行jar包 即可

java -jar 运行jar包时使用外部配置文件application.properties

linux下执行jar

  1. nohup java -Xmx512M -Xms512M -Djava.security.egd=/dev/urandom -jar message-service-1.0-SNAPSHOT.jar > /dev/null 2>&1 &

Linux下还有一个特殊的文件/dev/null,它就像一个无底洞,所有重定向到它的信息都会消失得无影无踪。

>/dev/null 2>&1

注意:此处的顺序不能更改,否则达不到想要的效果,此时先将标准输出重定向到 /dev/null,然后将标准错误重定向到标准输出,由于标准输出已经重定向到了/dev/null,因此标准错误也会重定向到/dev/null,于是一切静悄悄:-)

Spring Boot Maven 打包可执行Jar文件!的更多相关文章

  1. Spring Boot Maven 打包可执行Jar文件

    本文转载自:http://blog.csdn.net/smilecall/article/details/56288972 Maven pom.xml 必须包含 <packaging>ja ...

  2. Spring Boot Gradle 打包可执行Jar文件!

    使用Gradle构建项目,继承了Ant的灵活和Maven的生命周期管理,不再使用XML作为配置文件格式,采用了DSL格式,使得脚本更加简洁. 构建环境: jdk1.6以上,此处使用1.8 Gradle ...

  3. maven打包可执行jar文件运行报错

    起因 项目中同时依赖了Spring和MyBatis,并使用mybatis-spring集成MyBatis和Spring. 使用maven打包为可执行jar文件运行,打包插件为:maven-shade- ...

  4. spring boot maven打包可运行jar包

    普通打包之后在程序目录运行,或者编写bat运行时会提示“没有主清单属性”,这是因为并没有找到main()方法,需要我们指明告诉java程序 我bat中的代码 @echo off title mytit ...

  5. spring boot项目maven打包可执行JAR

    在pom.xml中添加如下配置: <!-- 打包可执行jar包 --> <plugin> <groupId>org.springframework.boot< ...

  6. 将 Spring boot 项目打成可执行Jar包,及相关注意事项(main-class、缺少 xsd、重复打包依赖)

    最近在看 spring boot 的东西,觉得很方便,很好用.对于一个简单的REST服务,都不要自己部署Tomcat了,直接在 IDE 里 run 一个包含 main 函数的主类就可以了. 但是,转念 ...

  7. Apache Maven 打包可执行jar

    在本文的 参考资料 部分,您将发现大量介绍 Maven 的入门教程.本文的 5 个技巧目的是帮助您解决即将出现的一些问题:使用 Maven 管理您的应用程序的生命周期时,将会出现的编程场景. 1. 可 ...

  8. Spring Boot Maven 打包 Jar

    Maven pom.xml 必须包含 <packaging>jar</packaging> <build> <plugins> <plugin&g ...

  9. Spring boot 项目导出可执行jar

    配置文件中添加插件 <plugin> <groupId>org.springframework.boot</groupId> <artifactId>s ...

随机推荐

  1. BZOJ.3624.[APIO2008]免费道路(Kruskal)

    题目链接 我们发现有些白边是必须加的,有些是多余的. 那么我们先把所有黑边加进去,然后把必须要加的白边找出来. 然后Kruskal,把必须要加的白边先加进去,小于K的话再加能加的白边.然后加黑边. 要 ...

  2. BZOJ 3564: [SHOI2014]信号增幅仪 最小圆覆盖

    3564: [SHOI2014]信号增幅仪 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=3564 Description 无线网络基站在 ...

  3. Moscow Subregional 2013. 部分题题解 (6/12)

    Moscow Subregional 2013. 比赛连接 http://opentrains.snarknews.info/~ejudge/team.cgi?contest_id=006570 总叙 ...

  4. 浅尝一致性Hash原理

    写在前面 在解决分布式系统中负载均衡的问题时候可以使用Hash算法让固定的一部分请求落到同一台服务器上,这样每台服务器固定处理一部分请求(并维护这些请求的信息),起到负载均衡的作用.但是普通的余数ha ...

  5. sql 计算两个经纬度点之间的距离

    这里用到的算法和地球半径等数据均来自网络,此文只作整理记录. 地球半径值采用赤道半径 6378137.0米,这是1980年的国际标准数据. //存储过程 CREATE FUNCTION [f_GetD ...

  6. 2018 dnc .NET Core、.NET开发的大型网站列表、各大公司.NET职位精选,C#王者归来

    简洁.优雅.高效的C#语言,神一样的C#创始人Anders Hejlsberg,async/await编译器级异步语法,N年前就有的lambda表达式,.NET Native媲美C++的原生编译性能, ...

  7. java将文件打包成ZIP压缩文件的工具类实例

    package com.lanp; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import ja ...

  8. redis 写磁盘出错 Can’t save in background: fork: Cannot allocate memory (转)

    查看 Redis 日志 发现系统在频繁报错: [26641] 18 Dec 04:02:14 * 1 changes in 900 seconds. Saving… [26641] 18 Dec 04 ...

  9. stm-ledstrip : Driver and test routine for WS2811 RGB-LED

    stm-ledstrip : Driver and test routine for WS2811 RGB-LED #include "ws2812.h" #include < ...

  10. oracle HA 高可用性具体解释(之二,深入解析TAF,以及HA框架)

    oracle HA 高可用性具体解释(之中的一个,client.server端服务具体解释):http://write.blog.csdn.net/postedit 我们已经看到TAF是的Oracle ...