views:

39

answers:

2

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>
A: 

I would say delete your build once from maven repos .m2 or any.

Then perform mvn clean from the parent project.

Then change a method in service. and build it using mvn clean install

Then see It will effect for sure

org.life.java
chanokim
@chanokim at build time you will need it built.
org.life.java
A: 

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>
Pascal Thivent
I changed version back to -SNAPSHOT and cleaned the POM as you suggested and restarted and cleaned everything. Now it seemes working but I am not sure which one fixed my problem - POM version name or redundant tags or. But thanks
chanokim
@chanokim I'm pretty sure it's the version, redundant tags are just... well, redundant :) But glad it's solved.
Pascal Thivent