英文:
Java Command vs spring-boot:run command
问题
我已经将您提供的内容翻译如下:
我在我的Spring Boot应用程序中集成了Vault,并且我遇到了一个非常奇怪的问题。当我使用以下命令运行应用程序时:
java -Dspring.profiles.active=dev -jar BatchProcessing-0.0.1-SNAPSHOT.jar
成功运行,但是当我使用以下命令运行时:
mvn spring-boot:run
我遇到了以下异常。
有人能否给我一个简要的描述,这两者之间可能有什么区别?谢谢!
Caused by: org.springframework.beans.factory.BeanCreationException: 在类路径资源[org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]中定义的名为 'vaultTemplate' 的 bean 创
建失败;通过工厂方法进行实例化时失败;嵌套异常是 org.springframework.beans.BeanInstantiationException: 通过工厂方法 'vaultTemplate' 进行实例化时抛出异常;嵌套异常是 org.springframework.beans.factory.Unsatisf
iedDependencyException: 在类路径资源[org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class] 中定义的名为 'vaultSessionManager' 的 bean 创
建失败;通过方法 'vaultSessionManager' 的参数 0 来表达的不满足的依赖关系;嵌套异常是 org.springframework.beans.factory.BeanCreationException: 在类路径资源[org/springframework/clo
ud/vault/config/VaultBootstrapConfiguration.class] 中定义的名为 'clientAuthentication' 的 bean 创
建失败;通过工厂方法进行实例化时失败;嵌套异常是 org.springframework.beans.BeanInstantiationException: 通过工厂方法 'clientAuthentication' 进行实例
化时抛出异常;嵌套异常是 java.lang.IllegalArgumentException: Token (spring.cloud.vault.toke
n) 必须不为空
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:484) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.5.RELEASE.jar
:5.2.5.RELEASE]
英文:
I have vault integrated with my spring-boot application and I am facing I guess a very weird issue. When I run my application using
java -Dspring.profiles.active=dev -jar BatchProcessing-0.0.1-SNAPSHOT.jar
runs successfully but when I use
mvn spring-boot:run
I get the below exception.
Can anyone please give me a brief description of what can be the difference between the two? Thank You!
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultTemplate' defined in class path resource [org/springframework/cloud/vault/config/VaultBootst
rapConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.vault.co
re.VaultTemplate]: Factory method 'vaultTemplate' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vaultSession
Manager' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]: Unsatisfied dependency expressed through method 'vaultSessionManager' parameter
0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientAuthentication' defined in class path resource [org/springframework/cloud/vault
/config/VaultBootstrapConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.sprin
gframework.vault.authentication.ClientAuthentication]: Factory method 'clientAuthentication' threw exception; nested exception is java.lang.IllegalArgumentException: Token (spring.cloud.vault.toke
n) must not be empty
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:484) ~[spring-beans-5.2.5.RELEASE.jar:5.2.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.5.RELEASE.jar
:5.2.5.RELEASE]
答案1
得分: 1
如果您想在使用Maven插件运行时激活配置文件,您必须像这样传递配置文件:
mvn spring-boot:run -Dspring-boot.run.profiles=dev
英文:
If you want to activate a profile when running with the Maven Plugin you must pass the profile like this:
mvn spring-boot:run -Dspring-boot.run.profiles=dev
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论