首页 > 其他分享 >springboot多环境开发兼容问题(Maven和boot)

springboot多环境开发兼容问题(Maven和boot)

时间:2023-02-16 20:23:08浏览次数:32  
标签:springboot 兼容问题 spring boot maven test org

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.itheima</groupId>
<artifactId>springboot_05_maven_and_boot_profile</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot_05_maven_and_boot_profile</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- 对资源文件开启对默认占位符的解析-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<useDefaultDelimiters>true</useDefaultDelimiters>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<!-- 开发环境-->
<profile>
<id>dev</id>
<properties>
<profile.active>dev</profile.active>
</properties>
</profile>
<!--生产环境-->
<profile>
<id>pro</id>
<properties>
<profile.active>pro</profile.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- 测试环境-->
<profile>
<id>test</id>
<properties>
<profile.active>test</profile.active>
</properties>
</profile>
</profiles>


</project>

在maven中设置多环境,在SpringBoot中的配置文件中.yml中应用maven属性

#设置启用的环境
spring:
  profiles:
    active: ${profile.active}
---
#开发
spring:
  profiles: dev
server:
  port: 80
---
#生产
spring:
  profiles: pro
server:
  port: 81
---
#测试
spring:
  profiles: test
server:
  port: 82

 

标签:springboot,兼容问题,spring,boot,maven,test,org
From: https://www.cnblogs.com/fxzm/p/17128163.html

相关文章

  • 基于spring-boot-starter-JDBC组件的通用增删改查
    前言配合嵌入式数据库使用,比如H2,sqlite嵌入式关系型数据,很香!pom<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc......
  • springboot---多环境启动命令格式
    一、多环境命令启动maven插件中首先clean,再package打包,(修改字符集为UTF-8)使用cmd命令java-jars(Tab键自动补全) -spring.profiles.active=test启动项目  修改端......
  • Springboot项目中注入bean失败的问题排查
    Springboot项目中注入bean失败的问题排查这是一个Spring常见的问题,下面我们从测试方法和普通方法出问题两个角度来下如何解决测试方法先查看目录是否有误测试类的包名......
  • 【IMX6ULL学习笔记】三、U-BOOT Makefile详解
    00、通识版本号VERSION=2016//主版本号PATCHLEVEL=03 //补丁版本号SUBLEVEL= //次版本号EXTRAVERSION=//附加版本信息NAME= //名字有关的,一般......
  • springboot基础配置yml
    yaml语法规则大小写敏感属性层级关系使用多行描述,每行结尾使用冒号结束使用缩进表示层级关系,同层级左侧对齐,只允许使用空格(不允许使用Tab键)属性值前面添加空格(属性名与属......
  • springboot自定义校验工具类
    参考:https://betheme.net/news/txtlist_i120686v.html?action=onClickhttps://www.ngui.cc/el/2571188.html?action=onClick一、原生注解在springboot中,我们可以使用ja......
  • SpringBoot
    一.SpringBoot 1.1SpringBoot概述1.1.1什么是SpringBootSpringBoot是Spring项目中的一个子工程,与我们所熟知的Spring-framework同属于spring的产品:其最主......
  • springboot 使用微信支付
    参考:Java实现微信支付_被编程征服的秃发女子的博客-CSDN博客一.微信支付流程支付流程:用户点击支付按钮调用接口[/deposit]=>返回给小程序payInfo和订单编号orderNum......
  • 前后端分离项目(vue+springboot)集成pageoffice实现在线编辑office文件
    前后端分离项目下使用PageOffice原理图集成步骤前端vue项目在您Vue项目的根目录下index.html中引用后端项目根目录下pageoffice.js文件。例如:<scripttype="text/......
  • SpringBoot集成MybatisPlus
    SpringBoot集成MybatisPlus一、依赖<properties><mybatis.plus.version>3.4.0</mybatis.plus.version></properties> <dependencies> ......