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 项目打包后无法通过命令行传入参数的更多相关文章

  1. spring boot 项目打包到maven仓库供其它模块使用

    在对spring boot项目进行打包发布的时候发现其它spring boot项目服务真正引用使用该spring boot包中的类 需对打包插件做如下修改: <build> <plu ...

  2. IDEA 快速将spring boot项目打包成jar包,简单快速有效

    原文地址;https://blog.csdn.net/chen846262292/article/details/80701101  https://www.cnblogs.com/chrischen ...

  3. 如何将Spring Boot项目打包部署到外部Tomcat

    1.项目打包     项目开发结束后,需要打包部署到外部服务器的Tomcat上,主要有几种方式. (1)生成jar包 cd 项目跟目录(和pom.xml同级)mvn clean package## 或 ...

  4. IntelliJ IDEA下spring boot项目打包

    Spring Boot自带Tomcat插件,可以直接编写启动类,开启Tomcat服务 springboot适合前后端分离,打成jar进行部署更合适 application.properties配置端口 ...

  5. 在IDEA中如何将Spring boot项目打包成可执行的jar包并发布到linux服务

    这两年微服务很流行,这里简单介绍一下如何将自己使用idea写的微服务打包成一个可执行的jar包,并发布到linux服务器的步骤.因为spring boot有内置的tomcat所以一般使用内置的tomc ...

  6. 【spring Boot】2.在Myecplise上把spring Boot项目打包 war包和jar包

    ========================================================第一部分======================================== ...

  7. apollo命令行传入参数

    Java apollo客户端运行配置 需要在META-INF中创建app.properties文件,以配置app.id 还需要在/opt/settings/server.properties或C:/o ...

  8. hive 命令行传入参数

    azkban实现任务重跑 我们执行sql的方式是将hql文件上传到服务器本地.然后执行shell命令 hive " -f ./test_scheduler.hql 注:hive -e 是执行 ...

  9. spring boot项目打包成jar后请求访问乱码解决

    在启动jar的时候添加一个配置  -Dfile.encoding=utf-8  java -Dfile.encoding=utf-8 -jar xxxxtest-0.1.jar

随机推荐

  1. AIX弱口令解密

    1.看下我们的AIX弱口令如果是图中的这种那么我们就可以通过以下脚本来完成转换 2.打开kali给脚本丢进去自动生成下图这种格式,转换完成后保存通过john --w来跑. 脚本文件:保存为.bash ...

  2. 2019牛客暑期多校训练营(第一场)-A (单调栈)

    题目链接:https://ac.nowcoder.com/acm/contest/881/A 题意:给定两个长度均为n的数组a和b,求最大的p使得(a1,ap)和(b1,bp)等价,等价的定义为其任意 ...

  3. rtsp学习----海康RTSP客户端连接深入分析

    转载于:http://blog.csdn.net/zhouyongku/article/details/41546789 海康相机RTSP连接代码分析 最近在做海康相机rtsp连接获取音视频的工作,现 ...

  4. [转帖]Linux查找文件6个高效工具

    Linux查找文件6个高效工具 https://www.linuxrumen.com/rmxx/176.html 需要实操 -inname -type 等等. 1. 前言 我们使用Linux过程中,经 ...

  5. 自然语言处理工具hanlp 1.7.3版本更新内容一览

    HanLP 1.7.3 发布了.HanLP 是由一系列模型与算法组成的 Java 工具包,目标是普及自然语言处理在生产环境中的应用.HanLP 具备功能完善.性能高效.架构清晰.语料时新.可自定义的特 ...

  6. STM32程序内存分布

    参考文献:https://www.rt-thread.org/document/site/programming-manual/basic/basic/ 一般 MCU 包含的存储空间有:片内 Flas ...

  7. JS基础_数据类型-Boolean类型

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. html5_禁止复制网站内容

    ```//若是你不想别人复制你的网站内容,可以把这段js代码加到你网页上,即可屏蔽鼠标右键菜单.复制粘贴.选中等 有时候的需求是网站中有些内容不希望别人复制,那么就需要用代码控制.方法有多种:第一种: ...

  9. echarts图表数据信息动态获取

    第一步准备一个json文件echarts.json(名字无所谓),用来模拟从后台获取数据 { "name":["直达","营销广告",&qu ...

  10. Session的生命周期和工作原理

    一.什么是Session,如何使用?Session是用于存放用户与web服务器之间的会话,即服务器为客户端开辟的存储空间. 由于客户端与服务器之间的会话是无状态的机制,Session则可用于关联访问, ...