我想为sql jdbc驱动程序添加依赖项。以下是我在pom.xml中添加的片段
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.5.0.jre9-preview</version>
<scope>test</scope>
</dependency>
然后我右键单击该项目并单击maven Install,在这里我得到了一个构建失败的错误。它已经下载了jar文件,但我收到以下错误。
Console output:
- maven-compiler-plugin:3.1:compile (default-compile) @ hybridFramework ---
[INFO] Changes detected - recompiling the module!
[
INFO] Compiling 27 source files to C:\Automation Testing softwares\seleniumHybridFramework-master\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 37.761 s
[INFO] Finished at: 2018-03-29T17:20:22+05:30
[INFO] Final Memory: 13M/45M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project hybridFramework: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[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
任何人都可以帮我吗?..
答案 0 :(得分:1)
答案 1 :(得分:1)
我使用的是eclipse IDE 右键单击项目 - &gt;构建路径 - >配置构建路径 - &gt;库
在那里配置JDK而不是JRE
答案 2 :(得分:0)
Maven是一个外部工具。您的IDE可以通过右键单击来调用它,但它基本上是外部工具。默认情况下,它使用您的JAVA_HOME变量(应该指向JDK而不是JRE)。例如,您可以查看:
C:\Users\User>echo %JAVA_HOME%
Output: C:\Program Files\Java\jdk1.8.0_152
您也可以使用
mvn -Dmaven.compiler.fork=true -Dmaven.compiler.executable=/path/to/the/javac compile
用于使用特定编译器进行编译,但我想这不是你的问题。只需正确设置你的JAVA_HOME即可。您也可以尝试运行命令行maven。它将有助于调试更容易,并且基本上更清洁。也许IDE正在设置一个与系统版本不同的java版本。您可以查看
mvn -version
您也可以通过以下方式检查您是否拥有JDK或JRE:
javac -version (this will work if you have JDK)