我有带有 2 个属性文件的 Spring Boot 服务器:application-local.properties和application-test.properties
在每个文件中,我都有用于开发机器和测试的配置。像这样开始:
-Dspring.profiles.active=local
但是在新的 Spring Boot 项目中,我使用了.yaml配置文件。而且我不明白如何使用profileswith .yaml. 我尝试阅读文档,但什么也不懂。你能一步一步解释该怎么做吗?
我需要两个文件?
application-local.yaml 和 application-test.yaml
或者我需要在一个application.yaml文件中写入所有内容?如果在一个文件中,我如何分离配置?这是我的配置:
server:
path: ***
port: ***
cxf:
path: ***
spring.datasource:
type: com.zaxxer.hikari.HikariDataSource
driver-class-name: oracle.jdbc.OracleDriver
url: ***
username: ***
password: ***
hikari:
minimumIdle: 5
maximumPoolSize: 20
idleTimeout: 30000
poolName: SpringBootJPAHikariCP
maxLifetime: 2000000
connectionTimeout: 30000
connection-test-query: SELECT 1 FROM DUAL
spring.jpa:
show-sql: false
database-platform: org.hibernate.dialect.Oracle10gDialect
properties.hibernate.jdbc.batch_size: 30
properties.hibernate.cache.use_second_level_cache: false
hibernate:
ddl-auto: validate
spring.cache:
ehcache:
config: classpath:ehcache.xml
#app configs
my:
messages-max-count: 5
messages-delay: 100
schedulers-charge-delay: 100
client:
first-server-address: ***
second-server-address: ***
last-server-address: ***
enabled-client: FirstClient
我想创建测试配置文件并更改数据库 url(或更改为 postgreSql),更改maximumPoolSize属性
HUH函数
相关分类