spring boot 项目打包后无法通过命令行传入参数
java -jar .\tk-provider.jar --spring.profiles.active=test
本想用测试环境的配置文件运行项目可项目启动时一直是使用dev配置文件运行。
java -jar .\tk-provider.jar --spring.profiles.active=test
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/softwareWorkspace/hqtx/HqService/ServiceProvider/tk-provider/target/tk-provider.jar!/BOOT-INF/lib/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/softwareWorkspace/hqtx/HqService/ServiceProvider/tk-provider/target/tk-provider.jar!/BOOT-INF/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
====================> : Spring Boot 初始化环境变量
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.4.RELEASE)
2018-08-23 16:14:48.494 INFO 349004 --- [ main] com.hq.tk.TkApplication : Starting TkApplication v1.0-SNAPSHOT on longqin with PID 349004 (D:\softwareWorkspace\hqtx\HqService\ServiceProvider\tk-provider\target\tk-provider.jar started by Administrator in D:\softwareWorkspace\hqtx\HqService\ServiceProvider\tk-provider\target)
2018-08-23 16:14:48.497 DEBUG 349004 --- [ main] com.hq.tk.TkApplication : Running with Spring Boot v2.0.4.RELEASE, Spring v5.0.8.RELEASE
2018-08-23 16:14:48.498 INFO 349004 --- [ main] com.hq.tk.TkApplication : The following profiles are active: dev
尝试了无数遍启动都是出现: The following profiles are active: dev,快要崩溃了。后来冷静想了想 命令行的参数是通过 main函数中的args参数接收的,立马去查看启动类,果然。
一开始的写法,springApplication.run 没有传入args参数
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(SsoApplication.class);
//监听生命周期
springApplication.addListeners(new SpringBootApplicationStartup());
springApplication.run();
}
更改
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(SsoApplication.class);
//监听生命周期
springApplication.addListeners(new SpringBootApplicationStartup());
springApplication.run(args);
}
再次打包运行,出现 :The following profiles are active: test
java -jar .\tk-provider.jar --spring.profiles.active=test
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/softwareWorkspace/hqtx/HqService/ServiceProvider/tk-provider/target/tk-provider.jar!/BOOT-INF/lib/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/softwareWorkspace/hqtx/HqService/ServiceProvider/tk-provider/target/tk-provider.jar!/BOOT-INF/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
====================> : Spring Boot 初始化环境变量
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.4.RELEASE)
2018-08-23 16:30:58.961 INFO 348708 --- [ main] com.hq.tk.TkApplication : Starting TkApplication v1.0-SNAPSHOT on longqin with PID 348708 (D:\softwareWorkspace\hqtx\HqService\ServiceProvider\tk-provider\target\tk-provider.jar started by Administrator in D:\softwareWorkspace\hqtx\HqService\ServiceProvider\tk-provider\target)
2018-08-23 16:30:58.964 DEBUG 348708 --- [ main] com.hq.tk.TkApplication : Running with Spring Boot v2.0.4.RELEASE, Spring v5.0.8.RELEASE
2018-08-23 16:30:58.966 INFO 348708 --- [ main] com.hq.tk.TkApplication : The following profiles are active: test
作者:神马不是神
链接:https://www.jianshu.com/p/24c090994829
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
spring boot 项目打包后无法通过命令行传入参数的更多相关文章
- spring boot 项目打包到maven仓库供其它模块使用
在对spring boot项目进行打包发布的时候发现其它spring boot项目服务真正引用使用该spring boot包中的类 需对打包插件做如下修改: <build> <plu ...
- IDEA 快速将spring boot项目打包成jar包,简单快速有效
原文地址;https://blog.csdn.net/chen846262292/article/details/80701101 https://www.cnblogs.com/chrischen ...
- 如何将Spring Boot项目打包部署到外部Tomcat
1.项目打包 项目开发结束后,需要打包部署到外部服务器的Tomcat上,主要有几种方式. (1)生成jar包 cd 项目跟目录(和pom.xml同级)mvn clean package## 或 ...
- IntelliJ IDEA下spring boot项目打包
Spring Boot自带Tomcat插件,可以直接编写启动类,开启Tomcat服务 springboot适合前后端分离,打成jar进行部署更合适 application.properties配置端口 ...
- 在IDEA中如何将Spring boot项目打包成可执行的jar包并发布到linux服务
这两年微服务很流行,这里简单介绍一下如何将自己使用idea写的微服务打包成一个可执行的jar包,并发布到linux服务器的步骤.因为spring boot有内置的tomcat所以一般使用内置的tomc ...
- 【spring Boot】2.在Myecplise上把spring Boot项目打包 war包和jar包
========================================================第一部分======================================== ...
- apollo命令行传入参数
Java apollo客户端运行配置 需要在META-INF中创建app.properties文件,以配置app.id 还需要在/opt/settings/server.properties或C:/o ...
- hive 命令行传入参数
azkban实现任务重跑 我们执行sql的方式是将hql文件上传到服务器本地.然后执行shell命令 hive " -f ./test_scheduler.hql 注:hive -e 是执行 ...
- spring boot项目打包成jar后请求访问乱码解决
在启动jar的时候添加一个配置 -Dfile.encoding=utf-8 java -Dfile.encoding=utf-8 -jar xxxxtest-0.1.jar
随机推荐
- SQL注入之手工注入
手工注入 用的是墨者学院的靶场:传送门 涉及以下数据库: MySQL.Access.SqlServer(MSSQL).SQLite.MongoDB.Db2(IBM).PostgreSQL.Sybase ...
- [Python3] 038 函数式编程 偏函数
目录 函数式编程 之 偏函数 1. 关于强制类型转换 int 的补充 2. 利用 int 新建函数 3. functools.partial 函数式编程 之 偏函数 1. 关于强制类型转换 int 的 ...
- windows10专业版激活
[1]右击我的电脑->属性,查看激活情况 [2]管理员身份打开CMD [2.1]如果不知道CMD是什么东西 [2.2]如果上面那个也找不到,直接按windows键(就是ctrl和alt中间那个键 ...
- Git和Github的使用
Git和Github的基本操作 一.了解Git和Github 1.什么是GIT? Git是一个免费.开源的版本控制软件 2.什么是版本控制系统? 版本控制是一种记录一个或若干个文件内容变化,以便将来查 ...
- 不同浏览器之间的javascript和css兼容性问题
po主手头维护的网站是上世纪的作品.当时约摸ie所占的市场份额相当大,以至于开发人员都没有考虑到浏览器兼容性问题(这不科学!).怎奈po主是个强迫症阿.最近在修改的时候,还是没忍住,把兼容性问题解决了 ...
- LOJ576 「LibreOJ NOI Round #2」签到游戏
题目 先进行一个转化: 每次花费\(\gcd\limits_{i=l+1}^rB_i\)的代价,可以连\((l,r)\)这一条边. 然后我们需要求\(0\sim n\)的最小生成树. 根据Kruska ...
- Linux就该这么学——新手必须掌握的命令之我的第一个命令
1.Linux操作系统的开机进程(基本过程) (1).内核的引导: BIOS自检,安装BIOS默认设置的启动设备(硬盘)来启动.读取目录/boot目录下的内核文件 (2).运行init: 运行init ...
- Reatful规范
Reatful规范 drf框架的作用 作用:写接口 什么是接口: URL(前后台信息交互的媒介) 明确了请求方式,提供对应后台所需参数,请求url链接可以得到后台的相应数据 怎么写接口: 参照某种规则 ...
- 记一次完整的java项目压力测试
总结:通过这次压力测试,增加了对程序的理解:假定正常情况下方法执行时间为2秒,吞吐量为100/s,则并发为200/s:假设用户可接受范围为10s,那么并发量可以继续增加到1000/s,到这个时候一切还 ...
- redis 学习(5)-- 列表类型
redis 学习(5)-- 列表类型 列表特点 有序.可以重复.左右两边插入弹出 索引相关知识 索引从左往右,从0开始逐个增大 0 1 2 3 4 5 索引从右往左,从-1开始逐个减小 -6 -5 - ...