2010-05-03 47 views
1

我一直试图让activemq-maven-plugin在bundle的类路径中使用配置运行activemq。但是,我没有太多的运气。看来activemq-maven-plugin只是忽略了本地bundle的资源(resources/main/conf/activemq.properties)。我检查了jar和target/classes,并将它们构建到了正确的本地。如果我取出activemq.xml中的PropertyPlaceholderConfigurer bean,我能够使插件运行(mvn activemq:run)我是否做错了什么?activemq-maven-plugin忽略classpath中的文件?

这里是输出

[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 /主/资源/ 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 /主/资源/ CONF/activemq.properties

activemq.port=61616 

回答

0

我在尝试使用类路径时也遇到了问题。所以我不能帮你那里,但如果该文件的相对路径是够你试试这个:

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
<property name="location"> 
    <value>file:./etc/activemq-broker.properties</value> 
</property> 

+0

感谢。我足够的尝试了解类路径配置不起作用或不受支持。相对路径从他们的例子中起作用,但我很惊讶它不支持类路径,因为它是一种基本类型。由于该插件非常基础,我可能根本就不会使用它。 – 2010-05-30 18:00:54