我一直在尝试使用activemq-maven-plugin来运行activemq,并在bundle的classpath中进行配置。但是,我没有太多运气。看来activemq-maven-plugin只是忽略了本地bundle的资源(resources / main / conf / activemq.properties)。我检查了jar和目标/类,它们构建在正确的本地。如果我取出activemq.xml中的PropertyPlaceholderConfigurer bean,我能够运行插件(mvn activemq:run)我做错了吗?
这是输出
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to start ActiveMQ Broker
Embedded error: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [conf/activemq.properties] cannot be opened because it does not exist
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Mon May 03 15:56:05 PDT 2010
[INFO] Final Memory: 11M/79M
[INFO] ------------------------------------------------------------------------
这是pom.xml,我特定的插件通过文件查找activemq.xml,这是有效的。
但是,在activemq.xml
中<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>oc.test</groupId>
<artifactId>mq</artifactId>
<version>0.1</version>
<name>mq</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.activemq.tooling</groupId>
<artifactId>maven-activemq-plugin</artifactId>
<version>5.3.1</version>
<configuration>
<configUri>xbean:file:src/main/resources/conf/activemq.xml</configUri>
<fork>false</fork>
<systemProperties>
<property>
<name>javax.net.ssl.keyStorePassword</name>
<value>password</value>
</property>
<property>
<name>org.apache.activemq.default.directory.prefix</name>
<value>./target/</value>
</property>
</systemProperties>
</configuration>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.5</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
这是src / main / resources / conf / activemq.xml
<?xml version="1.0"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd
">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:conf/activemq.properties</value>
</property>
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="./data">
<!-- The transport connectors ActiveMQ will listen to -->
<transportConnectors>
<transportConnector name="openwire" uri="tcp://localhost:61616"/>
</transportConnectors>
</broker>
</beans>
这是src / main / resources / conf / activemq.properties
activemq.port=61616
答案 0 :(得分:0)
当我尝试使用类路径时,我也遇到了问题。所以我无法帮助你,但如果文件的相对路径足够你,试试这个:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>file:./etc/activemq-broker.properties</value>
</property>