Spring JMS注入导致应用程序无法启动
我们有一个 Spring 应用程序,用于发布和侦听远程应用程序服务器上的队列。我的发布者和监听器是基于 spring 的,在我们自己的应用程序服务器中进行监听。
我们的测试环境遇到的问题之一是另一个应用程序。服务器没有启动,因此当我们的测试应用程序启动并尝试使用其 connectionFactory 注入 JmsTemplate 时,它会崩溃,因为它不是有效的连接,并且我们的整个应用程序无法加载。这给我们小组中与 JMS 无关的其他开发人员带来了痛苦。他们想做的就是运行并测试他们的代码,但 JmsTemplate connectionFactory 已关闭。
有没有人有任何建议让 spring 忽略一些错误的注入,从而使我们的应用程序能够正常启动? 谢谢
We have a spring application that publishes and listens to queues on a remote application server. My publisher and listener which are spring based listen within our own application server.
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. This is causing grief with the other developers in our group that have nothing to do with JMS. All they want to do is run and test their code but the JmsTemplate connectionFactory is down.
Does anyone have any suggestion for enabling spring ignore some bad injections which will allow our application to start properly?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这可以通过定义单独的弹簧配置文件,然后在启动应用程序时将其作为参数传递到测试环境中来实现。那么你可以嘲笑或忽略任何豆子。
示例
JVM 参数/系统属性
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.
Example
JVM param / System property