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

南笙酒味 提交于 2019-12-24 02:08:09

问题


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>

回答1:


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>


来源:https://stackoverflow.com/questions/3880305/changes-in-dependent-modules-cannot-be-seen-in-other-module-in-maven-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!