开发者

Changes in dependent modules cannot be seen in other module in Maven Eclipse

开发者 https://www.devze.com 2023-01-19 14:10 出处:网络
I am working on a multi module project with m2eclipse. I set the maven to take care of开发者_如何学运维 resolving workspace dependencies. But when I make change on, say, service module, change is not

I am working on a multi module project with m2eclipse. I set the maven to take care of开发者_如何学运维 resolving workspace dependencies. But when I make change on, say, service module, change is not visible on other modules immediately. If I make new method in Service layer, it is not visible in WebApp layer. Sometimes even Run/maven install and refresh and Project/clean and Maven/Update Dependencies doesn't work. Can someone give me an idea on this problem?

My project structure looks like as follows:

parent module

<groupId>com.myproject</groupId>
<artifactId>einvites-parent</artifactId>
<modules>
  <module>myproject-common</module>
  <module>myproject-domain</module>
  <module>myproject-service</module>
  <module>myproject-web</module>
</modules>

service module

<parent>
    <artifactId>myproject-parent</artifactId>
    <groupId>com.myproject</groupId>
    <version>1.0</version>
</parent>
<groupId>com.myproject</groupId>
<artifactId>myproject-service</artifactId>

web module

<parent>
    <artifactId>myproject-parent</artifactId>
    <groupId>com.myproject</groupId>
    <version>1.0</version>
</parent>
<groupId>com.myproject</groupId>
<artifactId>myproject-web</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>myproject-web</name>
<dependencies>
    <dependency>
        <groupId>com.myproject</groupId>
        <artifactId>myproject-service</artifactId>
        <version>1.0</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>
</dependencies>


This is supposed to work; and it does for me. I'm really not sure if this will fix the problem but could try to change your POM to use a SNAPSHOT version i.e. something like 1.0-SNAPSHOT (you're supposed to use SNAPSHOT versions anyway for modules under active development).

By the way, there are lots of unnecessary and redundant stuff in your POMs. They should look like this:

service module

<project>
  ...
  <parent>
    <artifactId>myproject-parent</artifactId>
    <groupId>com.myproject</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <!--groupId>com.myproject</groupId--> <!-- no need, you inherit it -->
  <artifactId>myproject-service</artifactId>
  ...
</project>

web module

<project>
  ...
  <parent>
    <artifactId>myproject-parent</artifactId>
    <groupId>com.myproject</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <!--groupId>com.myproject</groupId-->  <!-- no need, you inherit it -->
  <artifactId>myproject-web</artifactId>
  <!--version>1.0</version-->  <!-- no need, you inherit it -->
  <packaging>war</packaging>
  <name>myproject-web</name>
  <dependencies>
    <dependency>
        <groupId>${project.groupId}</groupId> <!-- use the built-in properties instead -->
        <artifactId>myproject-service</artifactId>
        <version>${project.version}</version> <!-- use the built-in properties instead -->
        <!--type>jar</type-->  <!-- no need, that's the default -->
        <!--scope>compile</scope--> <!-- no need, that's the default -->
    </dependency>
  </dependencies>
  ...
</project>
0

精彩评论

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