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
随机推荐
- PostgreSQL SQL优化之NOT IN问题
在我们平时写SQL时,如果遇到需要排除某些数据时,往往使用id <> xxx and id <> xxx,进而改进为id not in (xxx, xxx); 这样写没有问题, ...
- GoAccess操作手册
名字 GoAccess - 可视化 Web 日志分析工具. 语法 goaccess [filename] [ options ... ] [-c][-M][-H][-q][-d][...] 描述 Go ...
- golang(2):基本数据类型和操作符
1). 文件名 & 关键字 & 标识符 . 所有go源码都以 .go 结尾 . 标识符以字母或下划线开头,大小写敏感 . _ 是特殊标识符,用来忽略结果 . 保留关键字 golang ...
- LintCode 64---合并排序数组
public class Solution { /* * @param A: sorted integer array A which has m elements, but size of A is ...
- colaui基础
监控 c-watch // 监控的方法函数 on 监控的参数名字 div(c-watch="fun on style" c-bind="styles") // ...
- 异常-User class threw exception: java.lang.IllegalStateException: Cannot call methods on a stopped SparkContext.
1 详细信息 User class threw exception: java.lang.IllegalStateException: Cannot call methods on a stopped ...
- 一、PHP和Apache实现多用户自助建站
一.环境搭建准备
- php获取当前网页地址
判断是否为https /** * 判断是否为https * @return bool 是https返回true;否则返回false */ function is_https() { if ( !emp ...
- python中的else语句
python语言和其它语言一样在支持else语句,通常else语句和if语句合用,完成程序的分支选择功能. 例如如下打印学成成绩代码: score = int(input("请输入成绩:&q ...
- Vue自行封装常用组件-倒计时
倒计时组件,比较复杂一点,大神勿调侃,精确到毫秒,因为项目中多次出现倒计时,所以拿出来分享下 使用方法:1.在父组件中引入"uni-countdown" //import uniC ...