开发者

Limiting available beans via Maven

I use Maven to manage my web application using Spring. I do have two main directories - /src/main/java and /src/test/java - where the all testing stuff lies (tests, mocks, etc). The tests run smoothly both from maven command line and my IDE. Problem is when I deploy my application and I get this message:

java.lang.IllegalStateException: More than one bean of type    [pl.m4ks.comics.dao.IComicDAO] found, you have to specify the name of the bean (@SpringBean(name="foo")) in order to resolve this conflict. Matched beans: comicDAO,comicDAOMock
 at org.apache.wicket.spring.injection.annot.AnnotProxyFieldValueFactory.getBeanNameOfClass(AnnotProxyFieldValueFactory.java:231)

But the problem is that comicDAOMock resides inside /scr/test directory and should be not visible during non-test deploy! I use

<context:component-scan base-package="pl.m4ks.comics"/>
<context:annotation-config />

in my context.xml (for testing I use other context where beans are wired manually).

In pom.xml I do have:

        <resources>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>**</include>
            </includes>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
        <resource>
            <directory>src/main/java</directory>
            <includes>
  开发者_如何学编程              <include>**</include>
            </includes>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>

    <testResources>
        <testResource>
            <directory>src/test/java</directory>
            <includes>
                <include>**</include>
            </includes>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </testResource>
        <testResource>
            <directory>src/test/resources</directory>
            <includes>
                <include>**</include>
            </includes>
            <excludes>
                <exclude>**/*.java</exclude>
            </excludes>
        </testResource>
    </testResources>

So I thought I separated them. How can I solve this, I mean to completely exclude all testing stuff from my deploy run (I run by 'mvn jetty:run' command)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜