Note that there are some explanatory texts on larger screens.

plurals
  1. POmaven build helper plugin issue
    primarykey
    data
    text
    <p>I'm using maven build helper to automatically add <code>integration-test/java</code> and <code>integration-test/resources</code> folders to my project <code>classpath</code>. It works great when I run my tests with <code>JUnit</code> in <code>Eclipse</code>, but got a problem when I ran the web project where Tomcat always pick up the test resources instead of the production one.</p> <p>My project structure is something like this:</p> <pre><code>DaoProject src/main/resources/datasource.properties src/main/resources/spring-data.xml src/main/java/.... WebProject src/main/resources/appContext.xml src/integration-test/java/com/mypkg/controller/MyControllerIT.java src/integration-test/resources/datasource.properties </code></pre> <p>The <code>appContext.xml</code> imports <code>spring-data.xml</code> which in turn loads <code>datasource.properties</code> as a propterties source place holder.</p> <p>appContext.xml contents:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"&gt; &lt;context:annotation-config /&gt; &lt;tx:annotation-driven/&gt; &lt;context:component-scan base-package="com.mypkg" /&gt; &lt;mvc:annotation-driven /&gt; &lt;mvc:resources mapping="/resources/**" location="/resources/" /&gt; &lt;bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource" p:defaultEncoding="UTF-8"&gt; &lt;property name="basenames"&gt; &lt;array&gt; &lt;value&gt;messages&lt;/value&gt; &lt;/array&gt; &lt;/property&gt; &lt;/bean&gt; &lt;import resource="classpath:datasource.xml" /&gt; </code></pre> <p></p> <p>datasource.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation= "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd" &gt; &lt;context:property-placeholder location="classpath:datasources.properties"/&gt; &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; &lt;property name="driverClassName" value="org.postgresql.Driver" /&gt; &lt;property name="url" value="${config.db.url}" /&gt; &lt;property name="username" value="${config.db.username}" /&gt; &lt;property name="password" value="${config.db.password}" /&gt; </code></pre> <p> </p> <p>pom.xml: </p> <pre><code>&lt;plugin&gt; &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt; &lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt; &lt;version&gt;1.7&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;add-integration-test-sources&lt;/id&gt; &lt;phase&gt;generate-test-sources&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;add-test-source&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;sources&gt; &lt;source&gt;src/integration-test/java&lt;/source&gt; &lt;/sources&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;add-integration-test-resources&lt;/id&gt; &lt;phase&gt;generate-test-resources&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;add-test-resource&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;resources&gt; &lt;resource&gt; &lt;directory&gt;src/integration-test/resources&lt;/directory&gt; &lt;/resource&gt; &lt;/resources&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload