Java 无法运行 maven 安装?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19074038/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to run maven install?
提问by Junior Hernando Huaman Flores
Hi a query I have configured my pom.xml, was downloaded all libraries except the library jdbc6 Oracle 11.2.0, so for now I've had to say, I do not understand why not download this library. My pom.xml is this:
嗨,我已经配置了我的 pom.xml,已下载除库 jdbc6 Oracle 11.2.0 之外的所有库,所以现在我不得不说,我不明白为什么不下载这个库。我的 pom.xml 是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bbva.sca</groupId>
<artifactId>adm</artifactId>
<name>AdmSCA</name>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<properties>
<java-version>1.6</java-version>
<org.springframework-version>3.0.5.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
</properties>
<repositories>
<repository>
<id>spring-release</id>
<name>Spring Release Repository</name>
<url>http://maven.springframework.org/release</url>
</repository>
<repository>
<id>jboss</id>
<name>jboss Repository</name>
<url>http://repository.jboss.org/maven2</url>
</repository>
<repository>
<id>ibilio maven-2</id>
<name>ibilio Repository</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
<repository>
<id>primefaces-repo</id>
<name>Primefaces Repository</name>
<url>http://repository.primefaces.org/</url>
</repository>
<repository>
<id>oracle</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://www.mvnsearch.org/maven2/</url>
</repository>
<repository>
<id>ibilio maven-1</id>
<name>ibilio Repository</name>
<url>http://download.java.net/maven/1</url>
</repository>
</repositories>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- Spring Hibernate -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.4.Final</version>
</dependency>
<!-- <dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency> -->
<!-- JSF -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.13</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.13</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>redmond</artifactId>
<version>1.0.9</version>
</dependency>
<!-- AspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj-version}</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
</exclusion>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
<scope>runtime</scope>
</dependency>
<!-- @Inject -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.sun.el</groupId>
<artifactId>el-ri</artifactId>
<version>1.0</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<additionalProjectnatures>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
</additionalProjectnatures>
<additionalBuildcommands>
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
</additionalBuildcommands>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>org.test.int1.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
While cleaning out my maven satisfactory, but when installing I get this error:
在清理我的 maven 时令人满意,但在安装时出现此错误:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building AdmSCA 1.0.0-BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ adm ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ adm ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 62 source files to C:\Users\PC\Documents\BBVA\Versiones\AdmSCA\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.044s
[INFO] Finished at: Sat Sep 28 22:08:13 COT 2013
[INFO] Final Memory: 5M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project adm: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre1.6.0_34\..\lib\tools.jar -> [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/MojoExecutionException
回答by Sander Verhagen
You need to install a JDK instead of, or in addition to, a JRE, and set up your JAVA_HOME to point to the JDK accordingly.
您需要安装 JDK 来代替 JRE,或者除了 JRE 之外,还需要设置 JAVA_HOME 以相应地指向 JDK。
As per the Maven installation instructions:
根据Maven 安装说明:
Maven is a Java tool, so you must have Java installed in order to proceed. More precisely, you need a Java Development Kit (JDK), the Java Runtime Environment (JRE) is not sufficient.
Maven 是一个 Java 工具,因此您必须安装 Java 才能继续。更准确地说,您需要一个 Java Development Kit (JDK),Java Runtime Environment (JRE) 是不够的。
Further to that:
更进一步:
make sure that
JAVA_HOME
exists in your user variables or in the system variables and it is set to the location of your JDK, e.g.C:\Program Files\Java\jdk1.5.0_02
确保
JAVA_HOME
存在于您的用户变量或系统变量中,并将其设置为 JDK 的位置,例如C:\Program Files\Java\jdk1.5.0_02
And slightly off-topic:
和稍微偏离主题:
and [make sure] that
%JAVA_HOME%\bin
is in yourPath
environment variable
并且[确保]它
%JAVA_HOME%\bin
在您的Path
环境变量中
回答by Akhilesh Singh
I believe you have two questions.
我相信你有两个问题。
Why no jdbc6 jar > Oracle jar is not available on Maven central repository. This is a proprietory file which you need to download from oracle site or get from your DBA team. Then you can install the jar file manually in your local repository. Refer http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
You need to run your maven with JDK and not JRE. If you are running from command prompt, you need to set JAVA_HOME to the JDK path. If you are running maven from some form of IDE, you need to set the Maven environment accordingly.
为什么没有 jdbc6 jar > Oracle jar 在 Maven 中央存储库上不可用。这是一个专有文件,您需要从 oracle 站点下载或从您的 DBA 团队获取。然后,您可以在本地存储库中手动安装 jar 文件。参考http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
您需要使用 JDK 而不是 JRE 运行您的 Maven。如果从命令提示符运行,则需要将 JAVA_HOME 设置为 JDK 路径。如果您从某种形式的 IDE 运行 maven,则需要相应地设置 Maven 环境。
回答by Sushil Rukhaiyar
This exception is because "C:\Program Files\Java\jre1.6.0_34..\lib\tools.jar " ,
这个异常是因为 "C:\Program Files\Java\jre1.6.0_34..\lib\tools.jar ",
as tools.jar is available in JDK not with JRE.
因为 tools.jar 在 JDK 中可用,而不是在 JRE 中。
If you are trying to use embedded mavan like in eclipse you need to update the installed JREs for eclipse with JDK installed directories
如果您尝试在 Eclipse 中使用嵌入式 mavan,则需要使用 JDK 安装目录更新已安装的 Eclipse JRE
go to the below options in eclipse
转到 eclipse 中的以下选项
windows--> preferences --> java --> installed JREs and click on add then locate the JDK installed directory.
windows--> 首选项--> java --> 已安装的JREs 并单击添加然后找到JDK 安装目录。