使用 openshift 部署 war 时的依赖问题

Dependency issues in deploying war using openshift

我在尝试将 war 文件部署到 openshift repository 时遇到问题。

错误是:

Could not resolve dependencies for project ... the following artifacts could not be found:

所有这些外部 jar 都包含在我项目的 WEB-INF folder 中,我也尝试添加本地存储库但仍然没有成功。

谁能帮我解决这个问题?

Image of error

这是我的 pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>SussolWebservice</groupId>
  <artifactId>SussolWebservice</artifactId>
  <version>ROOT</version>
  <packaging>war</packaging>
  <properties>
    <spring.version>4.0.1.RELEASE</spring.version>
 </properties>
  <dependencies>

      <dependency>
     <groupId>junit</groupId>
     <artifactId>junit</artifactId>
     <version>4.12</version>
     <scope>test</scope>
    </dependency>

   <!-- Spring dependencies -->
   <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>${spring.version}</version>
  </dependency>

 <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-web</artifactId>
   <version>${spring.version}</version>
 </dependency>

 <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${spring.version}</version>
 </dependency>
 <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.13</version>
 </dependency>
 <dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.5.3</version>
</dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.2.3</version>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
   <artifactId>commons-io</artifactId>
      <version>1.4</version>
    </dependency>
    <dependency>
   <groupId>commons-fileupload</groupId>
   <artifactId>commons-fileupload</artifactId>
   <version>1.2.2</version> <!-- makesure correct version here -->
</dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.2.3</version>
    </dependency>
  
   
    <dependency>
      <groupId>org.eclipse.jdt.core.compiler</groupId>
      <artifactId>ecj</artifactId>
      <version>4.4.2</version>
    </dependency>

    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
</dependency>
 <dependency>
         <groupId>weka</groupId>
         <artifactId>weka</artifactId>
         <scope>system</scope>
         <version>1.0</version>
         <systemPath>${basedir}\WebContent\WEB-INF\lib\weka.jar</systemPath>
    </dependency>
    <dependency>
         <groupId>opencsv</groupId>
         <artifactId>opencsv</artifactId>
         <scope>system</scope>
         <version>1.0</version>
         <systemPath>${basedir}\WebContent\WEB-INF\lib\opencsv-3.7.jar</systemPath>
    </dependency>
    <dependency>
         <groupId>logging</groupId>
         <artifactId>logging</artifactId>
         <scope>system</scope>
         <version>1.0</version>
         <systemPath>${basedir}\WebContent\WEB-INF\lib\slf4j-log4j12-1.7.1.jar</systemPath>
    </dependency>
    <dependency>
         <groupId>log</groupId>
         <artifactId>log</artifactId>
         <scope>system</scope>
         <version>1.0</version>
         <systemPath>${basedir}\WebContent\WEB-INF\lib\slf4j-api-1.7.1.jar</systemPath>
    </dependency>
    <dependency>
         <groupId>loggger</groupId>
         <artifactId>logger</artifactId>
         <scope>system</scope>
         <version>1.0</version>
         <systemPath>${basedir}\WebContent\WEB-INF\lib\log4j-1.2.17.jar</systemPath>
    </dependency>
    <dependency>
         <groupId>packagemgr</groupId>
         <artifactId>packagemgr</artifactId>
         <scope>system</scope>
         <version>1.0</version>
         <systemPath>${basedir}\WebContent\WEB-INF\lib\packageManager.jar</systemPath>
    </dependency>
    <dependency>
         <groupId>SOM</groupId>
         <artifactId>SOM</artifactId>
         <scope>system</scope>
         <version>1.0</version>
         <systemPath>${basedir}\WebContent\WEB-INF\lib\SelfOrganizingMap.jar</systemPath>
    </dependency>
  </dependencies>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

我检查了你的 pom,发现了一些与范围系统的依赖关系,这意味着你的 JDK 或容器在你在 pom 中提供的位置提供了那些 jar。

来自文档:

system This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.

provided

This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.

更多信息在这里:

https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope

很可能 openshift 没有像您的 POM 中作为系统路径提供的文件那样的文件。

您可以执行以下操作之一:

  1. 从依赖项中删除作用域和系统路径,这样 将使用默认(编译)范围,并且将使用那些 jar 包含在您的项目中。
  2. 将您需要的 jar 文件存储在您的 openshift 服务器上的一个文件夹中(例如 app-root/data),然后在您的 pom 中引用该文件夹。
  3. 如果您正在使用 Tomcat,并且此 Tomcat 上的所有应用程序 运行 都在使用您要共享的库,您可以随时将共享库存储在:tomcat-dir/common/lib(在这种情况下,不要忘记将范围更改为 "provided")。