从 MLLP 侦听器应用程序从 Spring 转换为 SpringBoot 时出错

问题描述

我一直在将遗留应用程序转换为 Springboot。该应用程序使用 Camel 为 HL7 消息创建一个 MLPP 侦听器。在 Springboot 版本中,我从 xml 加载 Camel 端点配置(就像在遗留应用程序中所做的那样)。这是文件和加载方法

@SpringBootApplication
@ComponentScan(basePackages = "foo.bar")
@ImportResource("classpath:camel-config.xml")
public class App {

    public static void main(String[] args) {
        SpringApplication.run(App.class,args);
    }
}

camel-context.xml:

<!-- enable Spring @Component scan -->
<context:component-scan base-package="foo.bar" />

<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
    <property name="ignoreMissingLocation" value="true" />
    <property name="locations">
            <list>
                <value>classpath:default.properties</value>
                <value>file:/opt/foo.bar/application.properties</value>
            </list>
    </property>
</bean>

<bean id="myhl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec">
    <property name="charset" value="iso-8859-1"/>
    <property name="validate" value="false"/>
</bean>

<camelContext xmlns="http://camel.apache.org/schema/spring" id="oruCamelContext">
    <contextScan />
    <camel:endpoint id="hl7listener" uri="mina2:tcp://{{endpoint.server}}:{{endpoint.port}}?sync=true&amp;codec=#myhl7codec" />
</camelContext>

<context:annotation-config />

如果我按原样运行代码,则会收到错误

无法注册 bean 'hl7listener'。已经定义了具有该名称的 bean 并且禁用了覆盖。

如果我添加

spring.main.allow-bean-deFinition-overriding=true

到 application.properties

应用程序运行完美 - 我只是不明白为什么这是必要的,以及如何“已经”注册 bean?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...