springboot配置多个yml文件

springboot配置多个yml文件

参考

springboot配置多个yml文件

maven(三)最详细的profile的使用

实战

为生产和开发分别配置一个profile。每个都有多个文件。

profile

每个profile都应该有唯一的id, 可以同时激活多个profile,每个profile提供一些配置信息。

<project>
    <profiles>
        <!-- profile的id应该唯一,但是当重复时,使用的是文件后面的配置。-->
        <profile>
            <id>dev</id>
            <properties>
                <spring.profiles.active>prod,prod-wechat</spring.profiles.active>
            </properties>
        </profile>
        <profile>
            <id>prod</id>
            <activation>
                <!--默认激活-->
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <spring.profiles.active>dev,wechat</spring.profiles.active>
            </properties>
        </profile>
    </profiles>
</project>
# application.yml文件
spring:
  profiles:
    active: @[email protected]
# application-prod-wechat.yml文件
xhpay:
    front: prod-wechat
# application-wechat.yml文件
xhpay:
    front: wechat

bugs

Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token
found character '@' that cannot start any token. (Do not use @ for indentation)
 in 'reader', line 4, column 13:
        active: @[email protected]

原文地址:https://www.cnblogs.com/mozq/p/12109059.html

时间: 2024-08-30 11:50:04

springboot配置多个yml文件的相关文章

SpringBoot使用@Value从yml文件取值为空--注入静态变量

SpringBoot使用@Value从yml文件取值为空--注入静态变量 1.application.yml中配置内容如下: pcacmgr:   publicCertFilePath: E:\\pcacmgr\\CerFiles\\xh_public.cer   encPublicCertFilePath: E:\\pcacmgr\\CerFiles\\hjzf_encPublic.cer   encPfxFilePath: E:\\pcacmgr\\CerFiles\\hjzf_encPfx

springboot加载application.yml文件null

话不多说,直接上代码 本人项目为maven项目 以下是项目结构 pom.xml文件 <?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=&

Spring boot 全局配置 properties或者yml文件报错

主要问题是没有扫描到配置文件 在pom文件里面<build>    </build>中加上以下代码就可以保证能扫描到了 <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.yml</include> <include>**/*.properties</include

SpringBoot入门-15(springboot配置freemarker使用YML)

https://blog.csdn.net/fengsi2009/article/details/78879924 application.yml spring: http: encoding: force: true charset: UTF-8 freemarker: allow-request-override: false cache: false check-template-location: true charset: UTF-8 content-type: text/html;

配置数据源和配置jpa的yml文件

spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver username: root password: root url: jdbc:mysql://localhost:3306/order_system?characterEncoding=utf-8&amp&serverTimezone=UTC&amp&useSSL=false jpa: hibernate: ddl-auto: update da

springboot配置hibernate jpa多数据源

这里我用的springboot项目,配置文件yml文件配置,gradle配置jar包依赖. 找了一天资料,终于整好了多数据源,步骤如下: application.yml: 1 spring: 2 datasource: 3 driver-class-name: com.mysql.jdbc.Driver 4 url: jdbc:mysql://localhost:3306/base?characterEncoding=utf8&useSSL=false #5.5.45+, 5.6.26+ and

springboot yml 文件配置oracle,提示账号密码错误

最近使用Spring boot,本来一直连接的是mysql数据库,一直没问题.昨天在更换了oracle数据库后,一直提示账号密码不正确,登录被拒绝.检查多次,检查账号密码一切正常,但就是连接不上oracle. java.sql.SQLException: ORA-01017: invalid username/password; logon denied at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445) at ora

使用SpringBoot的yml文件配置时踩的一个坑

问题描述:使用SpringBoot整合redis进行yml配置的时候,启动工程报错,提示加载application.yml配置文件失败: 17:18:27.430 [main] ERROR org.springframework.boot.SpringApplication - Application startup failed java.lang.IllegalStateException: Failed to load property source from location 'clas

SpringBoot学习:读取yml和properties文件的内容

一.在SpringBoot实现属性注入: 1).添加pom依赖jar包: 1 <!-- 支持 @ConfigurationProperties 注解 --> 2 <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-configuration-processor --> 3 <dependency> 4 <groupId>org.springframework