springboot打包配置流程以及动态获取运行环境


1.导入插件

<packaging>jar</packaging>

<build>
    <plugins>
        <plugin>
            <!--springbootmaven插件-->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>1.4.1.RELEASE</version>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

 

2.打包

cmd运行

mvn clean package install  完成打包

3.获取运行环境

spring:
cloud:
config:
uri: http://127.0.0.1:1299 #配置服务器
label: master #分支
name: plat-provider-application #github上面名称
# profile: test #环境
profile: ${spring.actives.profile} #获取运行的参数


cmd 输入

java -jar -Dspring.actives.profile=test xxx-1.0-SNAPSHOT.jar

 

--测试

在ereuka7001注册中心查看服务名称即可


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM