2017-03-04 25 views
0

POM.xml就像我粘貼在下面的東西。我已經嘗試了也有一些問題的Oracle依賴項。 我不明白 正常POM和彈簧引導POM之間有什麼區別。我開始知道它有一個<parent> 來解決版本衝突。除此之外,什麼錯誤都沒有在我的POM我需要知道如何糾正我的第一個彈簧引導POM

<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>com.Microservice</groupId> 
    <artifactId>Microservice</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>war</packaging> 
    <name>Microservice</name> 
    <description>Microservice for user registration</description> 
    <properties> 
     <java-version>1.7</java-version> 
     <springframework.version>4.3.0.RELEASE</springframework.version> 
     <springsecurity.version>4.0.4.RELEASE</springsecurity.version> 
     <jackson.version>2.7.5</jackson.version> 
     <hibernate.version>4.3.11.Final</hibernate.version> 
     <mysql.connector.version>5.1.31</mysql.connector.version> 
    </properties> 
    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.3.3.RELEASE</version> 
    </parent> 
    <dependencies> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-core</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context-support</artifactId> 
     </dependency> 
    </dependencies> 
    <build> 
     <finalName>Microservice</finalName> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.tomcat.maven</groupId> 
        <artifactId>tomcat7-maven-plugin</artifactId> 
        <version>2.2</version> 
        <configuration> 
         <path>/Microservice</path> 
         <port>8080</port> 
        </configuration> 
       </plugin> 

       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-war-plugin</artifactId> 
        <version>2.2</version> 
        <configuration> 
         <failOnMissingWebXml>false</failOnMissingWebXml> 
        </configuration> 
       </plugin> 
       <plugin> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <version>2.0.2</version> 
        <configuration> 
         <source>1.7</source> 
         <target>1.7</target> 
        </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.codehaus.mojo</groupId> 
        <artifactId>exec-maven-plugin</artifactId> 
        <configuration> 
         <mainClass>controller.SampleController</mainClass> 
        </configuration> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
    </build> 
</project> 

在行家與目標建立安裝

[INFO] Scanning for projects... 
[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building Microservice 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Microservice --- 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] Copying 0 resource 
[INFO] Copying 0 resource 
[INFO] 
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) @ Microservice --- 
[INFO] Compiling 1 source file to E:\maven\target\classes 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD FAILURE 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 2.102 s 
[INFO] Finished at: 2017-03-04T22:26:43+05:30 
[INFO] Final Memory: 10M/24M 
[INFO] ------------------------------------------------------------------------ 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project Microservice: Compilation failure 
[ERROR] Unable to locate the Javac Compiler in: 
[ERROR] C:\Program Files\Java\jre1.8.0_101\..\lib\tools.jar 
[ERROR] Please ensure you are using JDK 1.4 or above and 
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required). 
[ERROR] In most cases you can change the location of your Java 
[ERROR] installation by setting the JAVA_HOME environment variable. 
[ERROR] -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException 

請解釋我的錯誤和方法來解決它。

我已經包括了我的環境變量

I have included the snapshot of my environment variable

+1

確保在您的機器上正確設置了JAVA_HOME。你已經指定'1.7' jdk被用來構建插件('maven-compiler-plugin')來進行交叉檢查。 – nullpointer

+0

但我檢查了它。我是否應該包括箱子 –

+1

是的。在你的系統變量 - >'path' - >添加JAVA_HOME/bin。 – nullpointer

回答

1

快照這不是一個POM問題。將您的環境變量JAVA_HOME更改爲指向jdk目錄而不是jre。

+0

我已經包含了環境變量的快照 –

+0

你還需要在你的'path'環境變量中添加%JAVA_HOME%\ bin –

1

錯誤提示您嘗試使用Java運行時環境(JRE)編譯Java類。您需要Java Development Kit(JDK)來編譯Java類。

解決方案:安裝JDK並將JAVA_HOME環境變量更改爲JDK目錄。

+0

感謝你的回覆。但它不起作用 –

0

最後兩步幫我

1)建立路徑--->刪除JRE庫,並增加了在pom.xml中

<executable>C:\Program Files\Java\jdk1.7.0_79\bin\javac</executable>  
<fork>true</fork> 
性能 標準VM 位置

2)添加新