【问题标题】:How to correct my first spring boot POM如何纠正我的第一个弹簧靴 POM
【发布时间】:2017-07-24 17:45:08
【问题描述】:

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

请解释一下错误和解决方法。

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

【问题讨论】:

  • 确保在您的机器上正确设置了JAVA_HOME。您已指定 1.7 jdk 用于构建插件(maven-compiler-plugin)只是为了交叉检查。
  • 但我查过了。我应该包括最多 bin
  • 是的。在您的系统变量中 -> path -> 添加 JAVA_HOME/bin。
  • 这是我的路径变量 C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\ v1.0\;C:\Program Files\Java\jdk1.7.0_79\bin;%JAVA_HOME%\bin;C:\Program Files\Apache Software Foundation\apache-maven-3.3.9\bin;
  • C:\ProgramData\Oracle\Java\javapath 有什么内容?如果该位置有一些 jre 文件;尝试从你的路径变量中删除它

标签: java spring maven dependencies pom.xml


【解决方案1】:

最后两个步骤帮助了我

1) 构建路径---> 移除 JRE 库并添加新的属性 标准虚拟机 位置

2) 在 POM.xml 中添加

<executable>C:\Program Files\Java\jdk1.7.0_79\bin\javac</executable>    
<fork>true</fork>

【讨论】:

    【解决方案2】:

    错误提示您尝试使用 Java 运行时环境 (JRE) 编译 Java 类。您需要一个 Java 开发工具包 (JDK) 来编译 Java 类。

    解决方法:安装一个JDK,将JAVA_HOME环境变量改为JDK目录。

    【讨论】:

      【解决方案3】:

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

      【讨论】:

      • 我已经包含了环境变量的快照
      • 你还需要在path环境变量中添加%JAVA_HOME%\bin
      猜你喜欢
      • 2021-07-22
      • 2017-12-22
      • 2018-02-14
      • 2021-06-13
      • 2019-05-03
      • 2021-04-20
      • 1970-01-01
      • 2023-01-07
      • 2023-02-15
      相关资源
      最近更新 更多