2017-04-07 20 views
0

我似乎有一個pom.xml文件錯誤與依賴項/插件,我生成這個pom.xml文件通過將項目轉換爲Maven,然後只產生這個POM文件。查看下面的錯誤代碼。根據Eclipse STS(Java Spring),Java代碼本身不包含錯誤,因此導入了java代碼中導入所需的所有jar文件。pom.xml文件錯誤,由於依賴和/或插件

運行Java程序時控制檯錯誤打印:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory 
    at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:190) 
    at testingpushnotifications.Application.main(Application.java:10) 
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 2 more 

pom.xml文件顯示在一個Java Spring項目的錯誤。

<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>Spring-Android-Push-Notifications-FCM--master</groupId> 
    <artifactId>Spring-Android-Push-Notifications-FCM--master</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <build> 
    <resources> 
     <resource> 
     <directory>src/main/java</directory> 
     <excludes> 
      <exclude>**/*.java</exclude> 
     </excludes> 
     </resource> 
    </resources> 
    <plugins> 
     <plugin> <--- ERROR HERE 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>3.5.1</version> 
     <configuration> 
      <source/> 
      <target/> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 
</project> 

還有上線大紅色的X從上面的代碼@line 16 1.

錯誤日誌: '插件'

Multiple annotations found at this line: 
    - Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile 
    (execution: default-compile, phase: compile) 
    - CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.5.1 or one of its 
    dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:3.5.1: 
    ArtifactResolutionException: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:pom:3.5.1 from/to central 
    (https://repo.maven.apache.org/maven2): NullPointerException 
    - Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.5.1:testCompile 
    (execution: default-testCompile, phase: test-compile) 

pom.xml文件的錯誤line 16

CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.5.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:3.5.1: ArtifactResolutionException: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:pom:3.5.1 from/to central (https://repo.maven.apache.org/maven2): NullPointerException pom.xml /Spring-Android-Push-Notifications-FCM--master line 16 Maven Project Build Lifecycle Mapping Problem 

EDITED根據評論添加依賴關係;結果=剩餘的錯誤仍然未解決,沒有新的錯誤。

<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>Spring-Android-Push-Notifications-FCM--master</groupId> 
    <artifactId>Spring-Android-Push-Notifications-FCM--master</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <build> 
    <resources> 
     <resource> 
     <directory>src/main/java</directory> 
     <excludes> 
      <exclude>**/*.java</exclude> 
     </excludes> 
     </resource> 
    </resources> 
    <plugins> 
     <plugin> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>3.5.1</version> 
     <configuration> 
     <source>1.8</source> 
     <target>1.8</target> 
     <dependency> 
    <groupId>commons-logging</groupId> 
    <artifactId>commons-logging</artifactId> 
    <version>1.2</version> 
</dependency> 
     </configuration> 
     </plugin> 
    </plugins> 
    <pluginManagement> 
     <plugins> 
      <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> 
      <plugin> 
       <groupId>org.eclipse.m2e</groupId> 
       <artifactId>lifecycle-mapping</artifactId> 
       <version>1.0.0</version> 
       <configuration> 
        <lifecycleMappingMetadata> 
         <pluginExecutions> 
          <pluginExecution> 
           <pluginExecutionFilter> 
            <groupId> 
             org.apache.maven.plugins 
            </groupId> 
            <artifactId> 
             maven-compiler-plugin 
            </artifactId> 
            <versionRange> 
             [3.5.1,) 
            </versionRange> 
            <goals> 
             <goal>compile</goal> 
            </goals> 
           </pluginExecutionFilter> 
           <action> 
            <ignore></ignore> 
           </action> 
          </pluginExecution> 
         </pluginExecutions> 
        </lifecycleMappingMetadata> 
       </configuration> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
    </build> 
</project> 
+0

聽起來有點像你不能訪問你的Maven回購。 'mvn -X help:help'告訴你任何有用的東西? – ninj

回答

0

好像你不具備共享記錄的jar只需添加依賴你pom.xml的任何版本使用的是

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

只是嘗試添加Java版本的文件如果您正在使用Java 8並嘗試設置java路徑。

<source>1.8</source> 
<target>1.8</target> 
+0

管理添加這些代碼而不出現新錯誤,儘管它們沒有解決以前的錯誤。 – Rami

+0

您已經添加了commons-logging依賴項標籤,但是在錯誤的remove.Just中取出了外部的以及所有在標籤內的commons-logging依賴項標籤 – Moni

+0

謝謝但我已經放棄了這種方法,框架。 – Rami

1

你放錯了地方<dependency>標籤,它必須是內上<dependencies>標籤,它不是內<build>標籤,但它應該是這樣的

.... 
<version>0.0.1-SNAPSHOT</version> 

<dependencies> 
    <dependency> 
     <groupId>commons-logging</groupId> 
     <artifactId>commons-logging</artifactId> 
     <version>1.2</version> 
    </dependency> 
</dependencies> 

<build> 
.....