【问题标题】:Changes in dependent modules cannot be seen in other module in Maven Eclipse在 Maven Eclipse 中的其他模块中看不到依赖模块的变化
【发布时间】:2011-04-22 06:32:43
【问题描述】:

我正在使用 m2eclipse 开发一个多模块项目。我将 maven 设置为负责解决工作区依赖项。但是,当我对服务模块进行更改时,更改不会立即在其他模块上可见。如果我在服务层创建新方法,它在 WebApp 层是不可见的。有时甚至 Run/maven installrefreshProject/cleanMaven/Update Dependencies 都不起作用。有人可以就这个问题给我一个想法吗?

我的项目结构如下:

父模块

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

【问题讨论】:

  • But when I make change on, say, service module, change is not visible on other modules immediately. 这应该可以,而且对我有用。如果您可以提供允许重现问题的 pom,我建议您报告问题。
  • @Pascal Thivent 它也适用于我,但我认为在构建时他需要在构建网络之前构建服务
  • @org.lie.java:为什么?这就是启用工作区解析的全部意义所在,Eclipse “perma compile”应该让事情对你来说是透明的。

标签: java eclipse maven-2 m2eclipse


【解决方案1】:

这应该有效;它对我有用。我真的不确定这是否能解决问题,但可以尝试将您的 POM 更改为使用SNAPSHOT 版本,即类似1.0-SNAPSHOT 的东西(对于正在积极开发的模块,无论如何您都应该使用SNAPSHOT 版本) .

顺便说一句,您的 POM 中有很多不必要和多余的东西。它们应该如下所示:

服务模块

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

【讨论】:

  • 我将版本改回 -SNAPSHOT 并按照您的建议清理了 POM,然后重新启动并清理了所有内容。现在它似乎工作了,但我不确定哪一个解决了我的问题 - POM 版本名称或冗余标签或。不过谢谢
  • @chanokim 我很确定这是版本,冗余标签只是......好吧,冗余:)但很高兴它已经解决了。
猜你喜欢
  • 1970-01-01
  • 2023-04-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-10
  • 1970-01-01
  • 2023-01-28
  • 2021-09-02
相关资源
最近更新 更多