我尝试使用maven构建项目。每次我都可能意外收到错误
No compiler is provided in this environment. perhaps you are running on a jre rather than a jdk?
而且我可以再次运行构建,一切正常。
JAVA_HOME C:\Program Files\Java\jre1.8.0_40
M2_HOME C:\Program Files\Maven
D:\java_projects>mvn -version
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T23:58:10+03:00)
Maven home: C:\Program Files\Maven
Java version: 1.8.0_40, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jre1.8.0_40
Default locale: en_US, platform encoding: Cp1251
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
D:\java_projects>
的pom.xml:
<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.epam</groupId>
<artifactId>News</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<jdk.version>1.8</jdk.version>
<spring.version>4.1.5.RELEASE</spring.version>
<jstl.version>1.2</jstl.version>
<junit.version>4.12</junit.version>
<tiles.version>3.0.5</tiles.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.unitils</groupId>
<artifactId>unitils-dbunit</artifactId>
<version>3.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.springtestdbunit</groupId>
<artifactId>spring-test-dbunit</artifactId>
<version>1.2.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
我有90%的使用cmd(mvn包)和大约40%的使用Eclipse(Maven build)的错误
解决:
下载最新的JDK,更新JAVA_HOME,更新Window->Preferences->Java->Installed JREs
答案 0 :(得分:0)
如错误所示,您在jre
上运行它,选择您的jdk路径。
Window-&gt;偏好设置 - &gt; Java-&gt;已安装的JRE-&gt; jre1.8.0_40
你应该有一个JDK条目。如果没有指向JDK。
然后,
RightClick项目 - &gt; Maven - &gt;更新项目
答案 1 :(得分:0)
安装JDK并将Employee_Designation_History
设置为您的jdk路径。