java Maven 错误:包不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27637877/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 12:09:57  来源:igfitidea点击:

Maven error: package does not exist

javamavenjenkins

提问by user518066

I am able build my java project on my local machine, it builds successfully using maven. However, when I build it on a Jenkins machine, i get a compile error:

我能够在我的本地机器上构建我的 java 项目,它使用 maven 成功构建。但是,当我在 Jenkins 机器上构建它时,出现编译错误:

package javax.jmsdoes not exist

javax.jms不存在

What does this mean? Where is it looking for javax.jms? In local m2 repo, classpath?

这是什么意思?它在哪里寻找javax.jms?在本地 m2 存储库中,类路径?

I had to make the following changes to my pom.xml to get it to work on Linux:

我必须对我的 pom.xml 进行以下更改才能使其在 Linux 上运行:

a) Explicitly stated maven-site-plugin version to 2.1. org.apache.maven.plugins maven-site-plugin 2.1

a) 明确声明 maven-site-plugin 版本为 2.1。org.apache.maven.plugins maven-site-plugin 2.1

b) Changed maven-surefire-plugin version from 2.4.3 to 2.18.1 maven-surefire-plugin 2.18.1

b) 将 maven-surefire-plugin 版本从 2.4.3 更改为 2.18.1 maven-surefire-plugin 2.18.1

c) Added the following dependencies :

c) 添加了以下依赖项:

     <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
       <version>1.4</version>
     </dependency>

     <dependency>
        <groupId>commons-cli</groupId>
        <artifactId>commons-cli</artifactId>
        <version>1.2</version>
      </dependency>

      <dependency>
            <groupId>com.xx.yyy</groupId>
            <artifactId>jms</artifactId>
            <version>1.1</version>
      </dependency>

      <dependency>
            <groupId>com.xx.yyy</groupId>
            <artifactId>orm</artifactId>
            <version>3.1.0.5</version>
       </dependency>

       <dependency>
            <groupId>org.springframework.ldap</groupId>
            <artifactId>spring-ldap-core</artifactId>
            <version>1.3.0.RELEASE</version>
       </dependency>

Why do I have to change the pom.xml on Linux. The build works on my Windows 7 machine without changing the pom.xml.

为什么我必须在 Linux 上更改 pom.xml。该构建在我的 Windows 7 机器上运行,而无需更改 pom.xml。

回答by Yuriy Yunikov

First, try to check if you have correct dependency for Maven to get javax.jmspackages. You can try Apache Geronimodependency or JavaEE API. (Reference :What is the right Maven dependency for javax.jms.* classes?)

首先,尝试检查您是否有正确的 Maven 依赖项来获取javax.jms包。您可以尝试Apache Geronimo依赖或JavaEE API. (参考:javax.jms.* 类的正确 Maven 依赖是什么?

For Apache Geronimo

为了 Apache Geronimo

  <dependency>
    <groupId>org.apache.geronimo.specs</groupId>
    <artifactId>geronimo-jms_1.1_spec</artifactId>
    <version>1.1.1</version>
  </dependency>

For JavaEE API

为了 JavaEE API

   <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>6.0</version>
      <scope>provided</scope>
    </dependency>

Also, make sure you are building your application on Jenkinswith the following goals:

此外,请确保您基于Jenkins以下目标构建应用程序:

mvn clean install

After you build your application with Mavenon Jenkinsmachine, the package should appear in local m2 repofor Jenkins.

在机器Maven上构建应用程序后Jenkins,该包应出现在本地m2 repofor Jenkins.