zoukankan      html  css  js  c++  java
  • Spring Boot Maven 打包可执行Jar文件

    本文转载自:http://blog.csdn.net/smilecall/article/details/56288972

    Maven pom.xml 必须包含

    <packaging>jar</packaging> 
    <build>  
        <plugins>  
            <plugin>  
                <groupId>org.springframework.boot</groupId>  
                <artifactId>spring-boot-maven-plugin</artifactId>  
                <configuration>  
                    <fork>true</fork>  
                </configuration>  
            </plugin>  
        </plugins>  
    </build> 

    完整pox.xml

    <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.feedback</groupId>  
        <artifactId>feedback-service</artifactId>  
        <version>0.1.0</version>  
        <packaging>jar</packaging>  
      
        <properties>  
            <java.version>1.8</java.version>  
        </properties>  
          
        <parent>  
            <groupId>org.springframework.boot</groupId>  
            <artifactId>spring-boot-starter-parent</artifactId>  
            <version>1.3.0.RELEASE</version>  
        </parent>  
          
        <dependencies>  
            <!-- spring boot -->  
            <dependency>  
                <groupId>org.springframework.boot</groupId>  
                <artifactId>spring-boot-starter-web</artifactId>  
            </dependency>  
            <dependency>  
                <groupId>org.springframework.boot</groupId>  
                <artifactId>spring-boot-starter-data-jpa</artifactId>  
            </dependency>  
              
            <!-- mysql数据库 -->  
            <dependency>  
                <groupId>mysql</groupId>  
                <artifactId>mysql-connector-java</artifactId>  
            </dependency>  
              
            <!-- commons-lang -->  
            <dependency>  
                <groupId>commons-lang</groupId>  
                <artifactId>commons-lang</artifactId>  
                <version>2.6</version>  
            </dependency>  
        </dependencies>  
          
        <!-- jar -->  
        <build>  
            <plugins>  
                <plugin>  
                    <groupId>org.springframework.boot</groupId>  
                    <artifactId>spring-boot-maven-plugin</artifactId>  
                    <configuration>  
                        <fork>true</fork>  
                    </configuration>  
                </plugin>  
            </plugins>  
        </build>  
    </project>

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

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

    如上生成的jar文件在:D:programmereclipsefeedback-service arget  文件夹中

    Java -jar 运行jar包 即可

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

  • 相关阅读:
    Java项目往数据库中插入数据,出现中文乱码
    转-取字符串中值(精辟)
    转-js对数组的操作(精辟)
    get、post(菜鸟教程转)
    (转)style/getComputerStyle/currentStyle
    去除默认样式
    link和import
    编辑中
    CSS的transfrom ransition
    css中 Span 元素的 width 属性无效果原因及多种解决方案(转自http://www.cnblogs.com/hnyei/archive/2012/03/12/2392026.html)
  • 原文地址:https://www.cnblogs.com/wpcnblog/p/7278806.html
Copyright © 2011-2022 走看看