[英]How to correct my first spring boot POM
The POM.xml is like something like i have pasted below. POM.xml就像我下面粘贴的一样。 I have tried the oracle dependency that also have some problem. 我尝试了也有一些问题的oracle依赖项。 I do not understand what are the differences between normal POM and spring boot POM. 我不了解普通POM和Spring Boot POM有什么区别。 I came to know it have a <parent>
to resolve version conflict. 我知道它有一个<parent>
来解决版本冲突。 Apart from that what mistakes are there in my POM i need to know 除此之外,我需要知道我的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>
on maven build with goal install 在目标安装的Maven构建中
[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
Please explain me the error and way to solve it. 请向我解释错误和解决方法。
I have included the snapshot of my environment variable 我已经包含了我的环境变量的快照
This is not a pom issue. 这不是pom问题。 Change your environment variable JAVA_HOME to point to a jdk directory rather than jre. 将环境变量JAVA_HOME更改为指向jdk目录而不是jre。
The error is telling you that you tried to compile java classes with a Java Runtime Environment (JRE). 该错误告诉您您尝试使用Java运行时环境(JRE)编译Java类。 You need a Java Development Kit (JDK) to compile java classes. 您需要Java开发套件(JDK)来编译Java类。
Solution: Install a JDK and change to JAVA_HOME enviroment variable to the JDK directory. 解决方案:安装一个JDK,并将JAVA_HOME环境变量更改为JDK目录。
Finally two steps helped me 最后两步帮助了我
1) Build path---> Removing the JRE library and adding new with properties Standard VM Location 1)构建路径--->删除JRE库并添加新的属性标准VM位置
2) Added in POM.xml 2)在POM.xml中添加
<executable>C:\Program Files\Java\jdk1.7.0_79\bin\javac</executable>
<fork>true</fork>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.