在Maven Eclipse中的其他模块中看不到从属模块的更改 [英] Changes in dependent modules cannot be seen in other module in Maven Eclipse

查看:93
本文介绍了在Maven Eclipse中的其他模块中看不到从属模块的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用m2eclipse进行多模块项目.我将Maven设置为解决工作区依赖项.但是,当我对服务模块进行更改时,更改不会立即在其他模块上可见.如果我在Service层中创建新方法,则它在WebApp层中不可见.有时甚至运行/maven安装刷新 Project/clean Maven/Update Dependencies 都不起作用.有人可以给我一个关于这个问题的想法吗?

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?

我的项目结构如下:

父模块

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

服务模块

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

网络模块

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

推荐答案

这应该有效;它为我做.我真的不确定这是否可以解决问题,但是可以尝试将您的POM更改为使用SNAPSHOT版本,例如1.0-SNAPSHOT之类的东西(无论如何,对于活跃开发中的模块,您都应该使用SNAPSHOT版本)

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).

顺便说一句,您的POM中有很多不必要和多余的东西.他们应该看起来像这样:

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

服务模块

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

网络模块

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

这篇关于在Maven Eclipse中的其他模块中看不到从属模块的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆