使用openshift部署战争的依赖性问题

时间:2016-04-08 06:45:10

标签: java maven deployment openshift war

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

错误是:

  

无法解析项目的依赖项...找不到以下工件:

所有这些外部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>

1 个答案:

答案 0 :(得分:1)

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

来自文档:

  

<强>系统   此范围与提供的类似,但您必须这样做   提供明确包含它的JAR。工件总是如此   可用,不会在存储库中查找。

     

提供

     

这很像编译,但表示您期望JDK   或者在运行时提供依赖性的容器。例如,何时   您可以为Java Enterprise Edition构建Web应用程序   设置对Servlet API和相关Java EE API的依赖   提供范围是因为Web容器提供了这些类。这个   scope仅在编译和测试类路径上可用,并且是   不是过渡性的。

此处提供更多信息:

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

openshift很可能没有像POM中那样提供系统文件的文件。

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

  1. 删除范围&amp;系统路径来自你的依赖,这种方式 将使用默认(编译)范围,那些jar将是 包含在你的项目中。
  2. 将您需要的jar文件存储在openshift服务器上的文件夹中(例如,app-root / data),并参考pom中的该文件夹。
  3. 如果您正在使用Tomcat,并且在此Tomcat上运行的所有应用程序都在使用您要共享的库,则可以始终将共享库存储在:tomcat-dir / common / lib中(不要忘记更改您的在这种情况下“提供”的范围)。