spring-boot分环境打包为war包
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包的更多相关文章
- Spring Boot:项目打包成war并发布到Tomcat上运行
一.修改pom文件 1. 因为SpringBoot中嵌入的有Tomcat,因此要移除嵌入式的Tomcat插件 <dependency> <groupId>org.springf ...
- 使用idea对spring boot项目打jar和war包[文件]
pom.xml文件编写 打JAR包时 <groupId>com.netcorner</groupId> <artifactId>demo</artifactI ...
- spring-boot分环境打包为tar包
1.pom配置 <!-- 多环境打包 start --> <profiles> <!-- 开发环境配置 --> <profile> <id> ...
- spring-boot分环境打包为jar包
1.pom配置 <!-- 多环境打包 start --> <profiles> <!-- 开发环境配置 --> <profile> <id> ...
- Spring Boot部署之 web项目war包运行
传统的部署方式:将项目打成war包,放入tomcat 的webapps目录下面,启动tomcat,即可访问. 具体打war包流程: 1.pom.xml配置文件修改: 2.改造启动类,如果是war包发布 ...
- Spring boot 分环境部署
一.如果配置文件为:application.properties时 1.application.properties用于填些公共文件 以下为不同环境的配置文件需要单独配置 application-de ...
- spring boot打包成war包的页面该放到哪里?
背景 经常有朋友问我,平时都是使用spring mvc,打包成war包发布到tomcat上,如何快速到切换到spring boot的war或者jar包上? 先来看看传统的war包样式是什么样子的? 1 ...
- 将 Spring boot 项目打成可执行Jar包,及相关注意事项(main-class、缺少 xsd、重复打包依赖)
最近在看 spring boot 的东西,觉得很方便,很好用.对于一个简单的REST服务,都不要自己部署Tomcat了,直接在 IDE 里 run 一个包含 main 函数的主类就可以了. 但是,转念 ...
- Spring Boot项目的打包和部署
补充一点:搜索了下别人Spring Boot部署方案,大多都说:①packaging设为war:②要添加Spring Boot的tomcat依赖:③修改output路径,但是使用STS新建Spring ...
随机推荐
- Service Fabric —— Actor / Stateless Service 概念
作者:潘罡 (Van Pan) @ Microsoft 上一节我们谈到了Stateful Service.在Service Fabric中,Stateful Service是理解Micro Servi ...
- Java基础-日期格式化DateFormat类简介
Java基础-日期格式化DateFormat类简介 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.DateFormat类概述 DateFormat 是日期/时间格式化子类的抽象 ...
- Block的copy时机
什么时候栈上的Block会复制到堆上呢? 1.调用Block的copy实例方法 2.Block作为函数返回值返回时 3.将Block赋值给附有__strong修饰符id类型的类或Block类型成员变量 ...
- 关于720p和1080p观看距离和效果
分类: 不同分辩率的信号源,对观看距离的要求是不同的.在标清时代,看电视台的画面,要离得好鬼远,否则就会觉得画面粗糙闪炼唔舒服.720P及1080P的观看距离又应该点样呢?系唔系买个50寸的平板电视要 ...
- ubuntu 使用小技巧
1. 查看网速 ethstatus ubuntu下用ethstatus可以监控实时的网卡带宽占用.这个软件能显示当前网卡的 RX 和 TX 速率,单位是Byte 安装 ethstatus 软件 sud ...
- HDU 2841 容斥 或 反演
$n,m <= 1e5$ ,$i<=n$,$j<=m$,求$(i⊥j)$对数 /** @Date : 2017-09-26 23:01:05 * @FileName: HDU 284 ...
- python 压缩每周生成的数据文件
为了便于整理部分业务数据,以及存储管理, 写了此脚本.后期如果有需求,再改一下. #!/usr/bin/env python #coding:utf8 import os,sys,time,comma ...
- react页面间传递参数
react-router页面跳转,带请求参数 this.context.router.push({pathname:'/car_datail',state:{item:"hello" ...
- 基于Vue + Vuex + Vue-router + Webpack 2.0打造微信界面
一.项目简介 基于Vue + Vuex + Vue-router + Webpack 2.0打造微信界面,实现了微信聊天.搜索.点赞.通讯录(快速导航).个人中心.模拟对话.朋友圈.设置等功能. 二. ...
- 关于UDP数据报引发“异步错误”的疑问
在UNP卷一第三版的第8章8.9小节中说到:如果udp服务器没有启动,udp客户端在使用sendto发送一行文本后,将会等待一个永远也不会出现的应答从而阻塞在recvfrom调用上. 由于服务器段不存 ...