代码之家  ›  专栏  ›  技术社区  ›  RafaelJan

从config.properties文件配置RabbitMQ主机和端口

  •  1
  • RafaelJan  · 技术社区  · 6 年前

    在里面 this

    <rabbit:connection-factory
    id="connectionFactory" host="somehost" port="5672"/>
    

    我想从config.properties文件中获取已配置参数的主机和端口值,该文件存在于项目中。

    可能吗?怎么用?

    另外,我的项目在scala中,但我认为这与Java项目在具体问题上没有什么不同

    1 回复  |  直到 6 年前
        1
  •  1
  •   RafaelJan    6 年前

    我发现 this ${ 配置参数 } . 详情如下:

    <rabbit:connection-factory id="rabbitConnectionFactory"    
                               host="${myproject.rabbitmq.connections.host}"
                               port="${myproject.rabbitmq.connections.port}"/>
    

    <rabbit:connection-factory id="rabbitConnectionFactory"    
                               host="${host}"
                               port="${port}"
                               virtual-host="${vhost}"
                               username="${username}" password="${password}" />
    

    我希望它能帮助其他人。