在Spring Boot多模块MAVE项目中的命令行上指定弹簧配置文件
我有 this Multi-Module Spring Boot(v2.7.0)项目。 它是相当肯定的 - 一个具有一个端点的控制器。
├───app
│ ├── pom.xml
│ └───src
│ └───main
│ └───java
│ └───com
│ └───rb
│ └─── App.java
├───controller
│ ├── pom.xml
│ └───src
│ └───main
│ └───java
│ └───com
│ └───rb
│ └─── MainController.java
└ pom.xml
我正在使用Maven 3.8.4。
我想使用此 Spring Boot的NICE快捷方式:
mvn clean install;
mvn spring-boot:run '-Dspring-boot.run.profiles=local' --projects app
(我是从PowerShell运行的,因此围绕参数的单引号)
Active-Profiles“ rel =” nofollow noreferrer 工作。该应用启动,运行正常,但使用默认
配置文件。
的语法起作用,或者为什么不起作用?
我的问题是 - 如何使这个不错 /maven-plugin/reference/htmlsingle/#运行“ rel =“ nofollow noreferrer”>更长的语法在春季作品中提到的:
mvn clean install;
mvn spring-boot:run '-Dspring-boot.run.jvmArguments="-Dspring.profiles.active=local"' --projects app
我还尝试在命令提示符上运行它,以省略这些单引号 - 带有相同的结果。
我将感谢有关问题的任何见解 - 我不是Java的专家 属性&命令行参数。
I've got this multi-module Spring Boot (v2.7.0) project.
It's fairly bare-bone - one Controller with one endpoint.
├───app
│ ├── pom.xml
│ └───src
│ └───main
│ └───java
│ └───com
│ └───rb
│ └─── App.java
├───controller
│ ├── pom.xml
│ └───src
│ └───main
│ └───java
│ └───com
│ └───rb
│ └─── MainController.java
└ pom.xml
I'm using Maven 3.8.4.
I would like to specify profile on the command line using this Spring Boot's nice shortcut:
mvn clean install;
mvn spring-boot:run '-Dspring-boot.run.profiles=local' --projects app
(I'm running it from PowerShell, hence the single quotes around the parameter)
However, it doesn't work. The app starts, runs fine, but with the default
profile.
My question is - how to make this nice syntax work, or why does it not work?
This uglier longer syntax mentioned in Spring's works:
mvn clean install;
mvn spring-boot:run '-Dspring-boot.run.jvmArguments="-Dspring.profiles.active=local"' --projects app
I also tried running it on Command Prompt omitting those single-quotes - with the same result.
I would appreciate any insights on what could be the issue - I'm no expert in Java's
properties & command-line arguments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用Spring-Boot Maven插件运行时,您必须像
MVN Spring-boot:run -dspring-boot.run.profiles = local
一样传递它。When you run with the spring-boot maven plugin, you have to pass it like this
mvn spring-boot:run -Dspring-boot.run.profiles=local