gpt4 book ai didi

java - Maven spring boot 带参数运行调试

转载 作者:IT老高 更新时间:2023-10-28 13:45:56 29 4
gpt4 key购买 nike

通常我使用命令运行我的 Spring Boot 应用程序:

mvn spring-boot:run -Drun.arguments=--server.port=9090 \
-Dpath.to.config.dir=/var/data/my/config/dir

我想设置自定义端口进行调试,所以我可以从 Eclipse 连接。当我从示例中添加参数时 https://docs.spring.io/spring-boot/docs/1.1.2.RELEASE/maven-plugin/examples/run-debug.html

mvn spring-boot:run -Drun.arguments=--server.port=9090 \
-Dpath.to.config.dir=/var/data/my/config/dir \
-Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8787"

它可以工作,但其他参数如 server.portpath.to.config.dir 不再被识别,我得到如下异常:

org.springframework.beans.factory.BeanDefinitionStoreException: Failed
to parse configuration class [com.my.app.Controller]; nested exception
is java.lang.IllegalArgumentException: Could not resolve placeholder
'path.to.config.dir' in string value
file:///${path.to.config.dir}/some.properties"

问题:如何在所有参数的情况下运行?

最佳答案

参数名称必须以spring-boot.为前缀,如-Dspring-boot.run.jvmArgument

Spring Boot documentation在我运行 Spring Boot 2.0.3

时为我提供了解决方案
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"

关于java - Maven spring boot 带参数运行调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36217949/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com