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 ...
随机推荐
- Python【OS】模块
import osprint(os.getcwd())#取当前工作目录#os.chmod("day6-os模块.py",2)#给文件/目录加权限,对Windows的下面不好使(1. ...
- Git5:Git操作远程仓库
目录 说明 一.git clone 二.git remote 三.git fetch 四.git pull 五.git push 说明 Git有很多优势,其中之一就是远程操作非常简便.本文详细介绍5个 ...
- mongo ttl索引
db.log_events.find() # 查找log_events里的所有数据 db.log_events.create ...
- Liunx常用命令(Mile)
记录一些平时经常用到的liunx命令,解决用过一段时间不用又忘记的问题.慢慢添加,持续更新~~~ 1.文件操作 a.zip.war包解压 war包 用的zip的方式压缩 ,也可以用的zip的 解压命令 ...
- Netty URL路由方案探讨
最近在用Netty做开发,需要提供一个http web server,供调用方调用.采用Netty本身提供的HttpServerCodec handler进行Http协议的解析,但是需要自己提供路由. ...
- spring boot使用自定义配置的线程池执行Async异步任务
一.增加配置属性类 package com.chhliu.springboot.async.configuration; import org.springframework.boot.context ...
- python 12306 车次数据获取
ssl._create_default_https_context = ssl._create_default_https_context train_data = '2018-10-20' head ...
- just test css
沃尔沃而 public void Commit() { if (_disposed) throw new InvalidOperationException(); if (_transaction = ...
- 简单几招,解决jQuery.getJSON的缓存问题
今天做测试工作,发现了一个令我费解的问题,jquery的getJson方法在firefox上运行可以得到返回的结果,但是在ie8上测试,竟发现没有发送请求,故不能取到任何返回的结果,经历了一翻周折,找 ...
- SpringBoot与异步任务、定时任务、邮件任务
异步任务 在需要开启异步的服务加上注解:@Async @Service public class AsyncService { //告诉SpringBoot这是一个异步任务,SpringBoot会自动 ...