简体   繁体   English

Spring JMS注入导致应用程序无法启动

[英]Spring JMS injection causing application not to startup

We have a spring application that publishes and listens to queues on a remote application server. 我们有一个Spring应用程序,它发布并侦听远程应用程序服务器上的队列。 My publisher and listener which are spring based listen within our own application server. 我的基于Spring的发布者和侦听器在我们自己的应用程序服务器中侦听。

One of the problems we have for our test environments is the other app. 我们的测试环境存在的问题之一是另一个应用程序。 server is not up so when our test application goes to start and it tries to inject JmsTemplate with its connectionFactory it blows up because it is not a valid connection and our entire application fails to load. 服务器未启动,因此当我们的测试应用程序启动时,它尝试使用其connectionFactory注入JmsTemplate,因为它不是有效的连接,并且整个应用程序无法加载,它会崩溃。 This is causing grief with the other developers in our group that have nothing to do with JMS. 这引起了我们小组中与JMS无关的其他开发人员的悲伤。 All they want to do is run and test their code but the JmsTemplate connectionFactory is down. 他们想要做的就是运行并测试他们的代码,但是JmsTemplate connectionFactory关闭了。

Does anyone have any suggestion for enabling spring ignore some bad injections which will allow our application to start properly? 有没有人建议启用弹簧,而忽略一些不良注射,这将使我们的应用正常启动? Thanks 谢谢

I believe this could be achieved by defining separate spring profiles and then passing it as a parameter in your test environments while starting your application. 我相信可以通过定义单独的弹簧轮廓,然后在启动应用程序时将其作为参数传递到测试环境中来实现。 You could mock or ignore any beans then. 然后,您可以嘲笑或忽略任何bean。 Example

import org.springframework.context.annotation.Profile;
@Profile("test")
public class AppConfigTest {

....
....
}

JVM param / System property JVM参数/系统属性

-Dspring.profiles.active=test

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM