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. extract_by_one 根据二维数组中某字段来提取数组信息,查看有无重复信息

    public function tt(){ $param = array( array ( 'hykno' => '2222222-CB', 'tcdk_fid' => '458B6D70 ...

  2. linux操作系统位数

    方法1:getconf LONG_BIT 查看 如下例子所示: 32位Linux系统显示32, 64位Linux系统显示64.最简单.快捷的方法. [root@DB-Server ~]# getcon ...

  3. ElasticStack系列之十二 & 搜索结果研究

    问题 使用 ElasticSearch 做搜索 时,比如用户输入 --> 柠檬,搜出来的结果 --> 柠檬汽水,柠檬味牙膏等在前面,真正想要的水果那个 柠檬 在后面.已经在中文分词中加了 ...

  4. 数据分析与展示---Pandas库入门

    简介 一:Pandas库的介绍 二:Pandas库的Series类型 (一)索引 (1)自动索引 (2)自定义索引 (二)Series类型创建 (1)列表创建 (2)标量值创建 (3)字典类型创建(将 ...

  5. webapi框架搭建-安全机制(一)

    本系列博客链接:webapi框架搭建系列博客 前言 webapi接口是开放给外部使用的,包括接口的地址,传参的规范,还有返回结果的说明.正因为接口的开放性,使得接口的安全很重要.试想一下,用抓包工具( ...

  6. 高维数据降维 国家自然科学基金项目 2009-2013 NSFC Dimensionality Reduction

    2013 基于数据降维和压缩感知的图像哈希理论与方法 唐振军 广西师范大学 多元时间序列数据挖掘中的特征表示和相似性度量方法研究 李海林 华侨大学       基于标签和多特征融合的图像语义空间学习技 ...

  7. Redis学习三:Redis数据类型

    一.Redis的五大数据类型 1.String(字符串) string是redis最基本的类型,你可以理解成与Memcached一模一样的类型,一个key对应一个value.string类型是二进制安 ...

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

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

  9. 洛谷P3953 [NOIP2017]逛公园

    K<=50,感觉可以DP 先建反图求出从n到各个点的最短路,然后在正图上DP 设f[当前点][比最短路多走的距离]=方案数 转移显然是 $f[v][res]=\sum f[u][res+tmp] ...

  10. 截取汉字 mb_sbstr()

    一.中文截取:mb_substr() mb_substr( $str, $start, $length, $encoding ) $str,需要截断的字符串 $start,截断开始处,起始处为0 $l ...