简体   繁体   English

Maven编译错误

[英]maven compilation errors

In my app I have two modules. 在我的应用程序中,我有两个模块。 I need to import classes from one of them to another. 我需要将类从其中一个导入到另一个。 for this I add a dependency to the second like this: 为此,我向第二个对象添加了一个依赖项,如下所示:

  <dependency>
      <groupId>com.messagedna-archive.mimeparser</groupId>
      <artifactId>MimeParser</artifactId>
      <version>1.0</version>
  </dependency>

and here is the part of the pom.xml of he module which must be imported: 这是必须导入的模块pom.xml的一部分:

  <groupId>com.messagedna-archive.mimeparser</groupId>
  <artifactId>MimeParser</artifactId>
  <version>1.0</version>

app is packeged by maven well, but when I'm trying to run it on server i see that: 该应用程序由maven打包,但是当我尝试在服务器上运行它时,我看到了:

java: package com.messagedna.mimeparser does not exist

(this is the package from the first module) in the class where I call these packages nothing is underlined red. (这是第一个模块中的程序包),在我称之为这些程序包的类中,没有任何带下划线的红色。

mvn -install executed for both methods. mvn -install对两种方法都执行。

how do you think, how this problem can be solved 您如何看待,如何解决这个问题

Maven modules produce artifacts. Maven模块产生工件。 In your case these are likely jar files. 在您的情况下,这些可能是jar文件。 So eventually you have two jar files which you need to add into the server classpath. 因此,最终您将需要将两个jar文件添加到服务器类路径中。 How to do this depends on the server, now you know the general idea. 如何执行此操作取决于服务器,现在您已经知道了基本概念。

ps/ "mvn -install" just copies the built artifacts into maven repo, not into your app classpath. ps /“ mvn -install”只是将构建的工件复制到maven存储库中,而不是复制到您的应用程序类路径中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM