java - 如何纠正我的第一个 Spring Boot POM

标签 java spring maven dependencies pom.xml

POM.xml 就像我在下面粘贴的内容。我尝试过oracle依赖,也有一些问题。 我不明白两者之间有什么区别 普通 POM 和 Spring Boot POM。我发现它有一个 <parent> 解决版本冲突。除此之外,我需要知道我的 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>

在 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

请解释一下错误以及解决方法。

我已经包含了我的环境变量的快照

I have included the snapshot of my environment variable

最佳答案

这不是一个pom问题。更改环境变量 JAVA_HOME 以指向 jdk 目录而不是 jre。

关于java - 如何纠正我的第一个 Spring Boot POM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42598804/

相关文章:

java - 3D 阵列如何工作?

java - 在Excel文件中存储数据时解释html标签

java - 如何将复选框放在 Swing 中的文本字段下方?

java - OneToMany 映射在 Controller CRUD Spring Boot Rest API 中不起作用

android - 将源代码从一个 Maven 项目复制到另一个

java - 如何在 JavaFX 2 中将 ArrayList 从一个场景传递到另一个场景?

java - 使用 spring data mongodb 存储库添加可选查询参数

eclipse - 如何使用 Eclipse IDE 在 spring xml 文件中搜索引用?

Spring 云配置服务 - Git 与 Native

java - 我无法通过maven获取jar文件