SpringBoot 项目的打包、部署

SpringBoot  ---  开发环境/测试环境和生产环境

application.properties是SpringBoot默认加载的,全局配置,则全部放在这里,假如有需要不同环境,配置不同的参数,比如日志、数据源,则放在不同的properties文件下面,在application.properties上面配置一句话即可:

spring.profiles.active=dev      ### 开发/测试/生产环境分别对应dev/test/pro

 

 

spring boot 启动

1、nohup  java -jar spring-boot01-1.0-SNAPSHOT.jar log.file 2>&&

这种情况适合在生产环境长时间运行。

 

#修改配置文件中一个属性,如:spring.profiles.active
nohup java -Xms1024m -Xmx1024m -jar xxxx.jar --spring.profiles.active=pro     ###优先级大于jar中的配置

 

其他

mvn clean package -Dmaven.test.skip=true

1,在使用mvn package进行编译、打包时,Maven会执行src/test/java中的JUnit测试用例,有时为了跳过测试,会使用参数-DskipTests和-Dmaven.test.skip=true,这两个参数的主要区别是:

-DskipTests,不执行测试用例,但编译测试用例类生成相应的class文件至target/test-classes下。

-Dmaven.test.skip=true,不执行测试用例,也不编译测试用例类。

 

或者在pom.xml文件中配置:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>
    </plugins>
</build>

 

 

SSL with  secure

server:
port: 8081
servlet:
context-path: /nonoscore
session:
cookie:
http-only: true
secure: true
tomcat:
protocol-header: X-Forwarded-Proto
remote-ip-header: X-Forwarded-For


不让null值返回前端

import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_NULL)

 

 

只能有一个main方法

代码中只能有一个main方法,不然在通过mvn package命令打包的时候,总是出错就报了个错误

错误详细内容是:

  1. Caused by: java.lang.IllegalStateException: Unable to find a single main class f  
  2. rom the following candidates [com.example.app.App, com.example.app.controller.Te  
  3. stPropertiesController]  

 

 

 maven打包排除某个目录

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.4</version> 
  <configuration>
    <packagingExcludes> 
      WEB-INF/classes/com/zjaisino/base/rpc/controller/testcase/*.* 
    </packagingExcludes> 
  </configuration>
</plugin>

 

 

spring banner 彩蛋生成器:

http://patorjk.com/software/taag/#p=display&f=Graffiti&t=222%0A

 

IDEA 好用的插件:

 https://blog.csdn.net/xlgen157387/article/details/78970079

 

posted @ 2017-11-15 21:00  江湖小谢*VIP  阅读(450)  评论(1编辑  收藏  举报