1.启动类修改

@EnableSwagger2
@SpringBootApplication
public class CustWebAcApplication extends SpringBootServletInitializer { public static void main(String[] args) {
SpringApplication.run(CustWebAcApplication.class, args);
} @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(CustWebAcApplication.class);
} @Bean
public RestTemplate restTemplate() { // SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
// // 设置超时 10s
// requestFactory.setConnectTimeout(10000);
// requestFactory.setReadTimeout(10000); RestTemplate restTemplate = new RestTemplate(); // 使用utf-8字符集
restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(Charset.forName("UTF-8"))); return restTemplate;
} }

2.pom配置

    <!-- 多环境打包 start -->
<profiles>
<!-- 开发环境配置 -->
<profile>
<id>dev</id>
<properties>
<profiles.active>dev</profiles.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- 测试环境配置 -->
<profile>
<id>test</id>
<properties>
<profiles.active>test</profiles.active>
</properties>
</profile>
<!-- 正式环境 -->
<profile>
<id>online</id>
<properties>
<profiles.active>online</profiles.active>
</properties>
</profile>
</profiles>
<!-- 多环境打包 end --> <build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.class</include>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>*.xml</include>
<include>*.properties</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources/conf/${profiles.active}</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<!--如果想在没有web.xml文件的情况下构建WAR,请设置为false. -->
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>

3.打包命令

mvn clean package -Dmaven.test.skip=true -Ptest

4.启动

将war包放到tomcat的webapps下,启动tomcat即可

spring-boot分环境打包为war包的更多相关文章

  1. Spring Boot:项目打包成war并发布到Tomcat上运行

    一.修改pom文件 1. 因为SpringBoot中嵌入的有Tomcat,因此要移除嵌入式的Tomcat插件 <dependency> <groupId>org.springf ...

  2. 使用idea对spring boot项目打jar和war包[文件]

    pom.xml文件编写 打JAR包时 <groupId>com.netcorner</groupId> <artifactId>demo</artifactI ...

  3. spring-boot分环境打包为tar包

    1.pom配置 <!-- 多环境打包 start --> <profiles> <!-- 开发环境配置 --> <profile> <id> ...

  4. spring-boot分环境打包为jar包

    1.pom配置 <!-- 多环境打包 start --> <profiles> <!-- 开发环境配置 --> <profile> <id> ...

  5. Spring Boot部署之 web项目war包运行

    传统的部署方式:将项目打成war包,放入tomcat 的webapps目录下面,启动tomcat,即可访问. 具体打war包流程: 1.pom.xml配置文件修改: 2.改造启动类,如果是war包发布 ...

  6. Spring boot 分环境部署

    一.如果配置文件为:application.properties时 1.application.properties用于填些公共文件 以下为不同环境的配置文件需要单独配置 application-de ...

  7. spring boot打包成war包的页面该放到哪里?

    背景 经常有朋友问我,平时都是使用spring mvc,打包成war包发布到tomcat上,如何快速到切换到spring boot的war或者jar包上? 先来看看传统的war包样式是什么样子的? 1 ...

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

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

  9. Spring Boot项目的打包和部署

    补充一点:搜索了下别人Spring Boot部署方案,大多都说:①packaging设为war:②要添加Spring Boot的tomcat依赖:③修改output路径,但是使用STS新建Spring ...

随机推荐

  1. P1486 [NOI2004]郁闷的出纳员

    P1486 [NOI2004]郁闷的出纳员 题目描述 OIER公司是一家大型专业化软件公司,有着数以万计的员工.作为一名出纳员,我的任务之一便是统计每位员工的工资.这本来是一份不错的工作,但是令人郁闷 ...

  2. JavaScript中的apply()和call()

    可以将call()和apply()看做是某个对象的方法,通过调用方法的形式来间接调用函数. call()和apply()的第一个实参是要调用函数的母对象,它是调用上下文,在函数体内通过this来获得对 ...

  3. Dubbo学习笔记2:Dubbo服务提供端与消费端应用的搭建

    Demo结构介绍 Demo使用Maven聚合功能,里面有三个模块,目录如下: 其中Consumer模块为服务消费者,里面TestConsumer和consumer.xml组成了基于Spring配置方式 ...

  4. CF869 E 二维BIT

    1代表建一个屏障,2代表去掉一个屏障,3询问是否两点相通. 仿造一维询问是否在同一区间的问题扩展到二维,树状数组维护区间标记即可,标记值可以直接2500进制不会爆LL. /** @Date : 201 ...

  5. ASP.NET配置文件Web.config 详细解释

    一.认识Web.config文件 Web.config文件是一个XML文本文件,它用来储存 ASP.NET Web 应用程序的配置信息(如最常用的设置ASP.NET Web 应用程序的身份验证方式), ...

  6. 渐变色之location概念.

    CHENYILONG Blog 渐变色之location概念.全屏幕13-12-22 上午10:18 © chenyilong. Powered by Postach.io Blog

  7. D. Makoto and a Blackboard(积性函数+DP)

    题目链接:http://codeforces.com/contest/1097/problem/D 题目大意:给你n和k,每一次可以选取n的因子代替n,然后问你k次操作之后,每个因子的期望. 具体思路 ...

  8. ==和equals区别

    java中的数据类型,可分为两类:  1.基本数据类型,也称原始数据类型.byte,short,char,int,long,float,double,boolean    他们之间的比较,应用双等号( ...

  9. tomcat发布html静态页面

    一.环境 在Linux系统安装JDK并配置环境变量,安装tomcat(在tomcat官网下载压缩包即可,我使用的是tomcat7 https://tomcat.apache.org/download- ...

  10. oracle11g 创建id自增长监听器的步骤与问题

    首先,我们通过sql/plus先建个TEST表 sql语句: CTEATE TABLE TEST( ID NUMBER, NAME VARCHAR2(20), PRIMARY KEY(ID) ); 通 ...