Giter VIP home page Giter VIP logo

Comments (6)

xuxiaowei-com-cn avatar xuxiaowei-com-cn commented on May 23, 2024 2
  1. 从下列打包可以看出,执行 mvn clean install 后,原来配置文件中是 [email protected]@.yml,打包后的产物是 application-dev.yml
  2. 也就是说,打包后的产物配置固定了,无法在程序启动时通过 参数 -Pxxx 修改配置了
  3. 只能在打包时指定 参数 -Pxxx,也就是说,一个包可能只能在一个环境中使用,如果配置发生了变化,也只能通过重新打包来解决此问题(启动时,全部使用参数进行指定是不现实的做法)

xuxiaowei@DESKTOP-8E6LUNV MINGW64 /d/IdeaProjects-jihulab.com/mirrors-gitee/log4j/pig (jdk17-dev)
$ mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:                                                    
[INFO]                                                                         
[INFO] pig                                                                [pom]
[INFO] pig-register                                                       [jar]
[INFO] pig-common                                                         [pom]
[INFO] pig-common-core                                                    [jar]
[INFO] pig-gateway                                                        [jar]
[INFO] pig-common-feign                                                   [jar]
[INFO] pig-common-mybatis                                                 [jar]
[INFO] pig-upms                                                           [pom]
[INFO] pig-upms-api                                                       [jar]
[INFO] pig-common-security                                                [jar]
[INFO] pig-common-log                                                     [jar]
[INFO] pig-auth                                                           [jar]
[INFO] pig-common-oss                                                     [jar]
[INFO] pig-common-swagger                                                 [jar]
[INFO] pig-common-xss                                                     [jar]
[INFO] pig-upms-biz                                                       [jar]
[INFO] pig-common-bom                                                     [pom]
[INFO] pig-common-datasource                                              [jar]
[INFO] pig-common-job                                                     [jar]
[INFO] pig-common-seata                                                   [jar]
[INFO] pig-visual                                                         [pom]
[INFO] pig-codegen                                                        [jar]
[INFO] pig-monitor                                                        [jar]
[INFO] pig-quartz                                                         [jar]
[INFO]
[INFO] -------------------------< com.pig4cloud:pig >--------------------------
[INFO] Building pig 3.7.1                                                [1/24]

******

[INFO] Reactor Summary for pig 3.7.1:
[INFO]
[INFO] pig ................................................ SUCCESS [  0.442 s]
[INFO] pig-register ....................................... SUCCESS [ 13.649 s]
[INFO] pig-common ......................................... SUCCESS [  0.030 s]
[INFO] pig-common-core .................................... SUCCESS [  3.235 s]
[INFO] pig-gateway ........................................ SUCCESS [  3.748 s]
[INFO] pig-common-feign ................................... SUCCESS [  1.440 s]
[INFO] pig-common-mybatis ................................. SUCCESS [  1.348 s]
[INFO] pig-upms ........................................... SUCCESS [  0.025 s]
[INFO] pig-upms-api ....................................... SUCCESS [  2.419 s]
[INFO] pig-common-security ................................ SUCCESS [  2.406 s]
[INFO] pig-common-log ..................................... SUCCESS [  1.427 s]
[INFO] pig-auth ........................................... SUCCESS [  2.966 s]
[INFO] pig-common-bom ..................................... SUCCESS [  0.022 s]
[INFO] pig-common-datasource .............................. SUCCESS [  0.869 s]
[INFO] pig-common-job ..................................... SUCCESS [  0.906 s]
[INFO] pig-common-seata ................................... SUCCESS [  0.874 s]
[INFO] pig-visual ......................................... SUCCESS [  0.021 s]
[INFO] pig-codegen ........................................ SUCCESS [  3.004 s]
[INFO] pig-monitor ........................................ SUCCESS [  1.229 s]
[INFO] pig-quartz ......................................... SUCCESS [  2.619 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  50.726 s
[INFO] Finished at: 2023-09-01T10:15:41+08:00
[INFO] ------------------------------------------------------------------------

xuxiaowei@DESKTOP-8E6LUNV MINGW64 /d/IdeaProjects-jihulab.com/mirrors-gitee/log4j/pig (jdk17-dev)
$ cat pig-gateway/src/main/resources/application.yml
server:     
  port: 9999
            
spring:     
  application:
    name: @artifactId@
  cloud:
    nacos:
      username: @nacos.username@
      password: @nacos.password@
      discovery:
        server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848}
        watch:
          enabled: true
        watch-delay: 1000
      config:
        server-addr: ${spring.cloud.nacos.discovery.server-addr}
  config:
    import:
      - optional:nacos:[email protected]@.yml
      - optional:nacos:${spring.application.name}[email protected]@.yml

xuxiaowei@DESKTOP-8E6LUNV MINGW64 /d/IdeaProjects-jihulab.com/mirrors-gitee/log4j/pig (jdk17-dev)
$ cat pig-gateway/target/classes/application.yml 
server:
  port: 9999

spring:
  application:
    name: pig-gateway
  cloud:
    nacos:
      username: nacos
      password: nacos
      discovery:
        server-addr: ${NACOS_HOST:pig-register}:${NACOS_PORT:8848}
        watch:
          enabled: true
        watch-delay: 1000
      config:
        server-addr: ${spring.cloud.nacos.discovery.server-addr}
  config:
    import:
      - optional:nacos:application-dev.yml
      - optional:nacos:${spring.application.name}-dev.yml

xuxiaowei@DESKTOP-8E6LUNV MINGW64 /d/IdeaProjects-jihulab.com/mirrors-gitee/log4j/pig (jdk17-dev)
$

from pig.

xuxiaowei-com-cn avatar xuxiaowei-com-cn commented on May 23, 2024

统一代码配置

https://github.com/pig-mesh/pig/blob/95d0091c3e74fb9d0246724619fc2a1bf0bd71cd/pig-gateway/src/main/resources/application.yml

image

from pig.

xuxiaowei-com-cn avatar xuxiaowei-com-cn commented on May 23, 2024

十二要素宣言:https://12factor.net/zh_cn/

https://github.com/pig-mesh/pig/blob/95d0091c3e74fb9d0246724619fc2a1bf0bd71cd/pig-gateway/src/main/resources/application.yml

image

from pig.

xuxiaowei-com-cn avatar xuxiaowei-com-cn commented on May 23, 2024

测试环境已通过,正式环境需要重新打包,如何保证正式环境的打包产物与测试环境相同?

  1. Maven 快照随时能修改、删除:在测试打包后,正式打包前,Maven 快照可能发生变化
  2. npm 包随时能修改、删除:在测试打包后,正式打包前,npm 包发生了变化
  3. docker 镜像随时能修改、删除:在测试打包后,正式打包前,docker 镜像发生了变化
  4. ......

from pig.

booniez avatar booniez commented on May 23, 2024

给 nacos 指定一个 namespace,从环境变量中去读取,就可以实现一份代码多端部署了吧。配置都放到了 nacos ,都是在 nacos 操作的。

from pig.

xuxiaowei-com-cn avatar xuxiaowei-com-cn commented on May 23, 2024

给 nacos 指定一个 namespace,从环境变量中去读取,就可以实现一份代码多端部署了吧。配置都放到了 nacos ,都是在 nacos 操作的。

理想状态下,所有“打包产物中的配置”,都可以使用环境变量进行修改

from pig.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.