客户要求服务部署到本地服务器上,服务是根据业务做了多模块。 原本的方案每多一个本地部署的需求,就在每个模块的 resources 下加一个文件夹,打包的时候通过选择 profiles 只打包那个文件夹下的配置,但是因为模块有点多,所以每次新增一堆东西很麻烦。
现在像减少重复的工作,试图把每个模块的 profiles 移除掉,统一使用父 pom 中的 profiles ,在里面配置变量,因为项目只用了 mysql ,redis ,所以配置项也不多,配置如下:
# applicaiton.yml spring: profiles: active: @profiles.active@ server: port: 8010 # application-prod.yml spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver dynamic: primary: master datasource: master: url: @mysql.master.url@ username: @mysql.master.username@ password: @mysql.master.password@ slave: url: @mysql.slave.url@ username: @mysql.slave.username@ password: @mysql.slave.password@ redis: host: @redis.host@ sentinel: master: @redis.sentinel.master@ nodes: @redis.sentinel.nodes@ password: @redis.password@ timeout: 10s 但是尝试了下打包,发现并不能正确写入变量,请问还有什么好的解决方案吗。(配置中心怕是不行,领导估计是不让用)
