在pom.xml中添加sql jdbc驱动程序的Maven依赖项时的Build Failure错误

时间:2021-05-31 19:33:34

I want to add the dependency for sql jdbc driver. Following is the snippet which I have added in pom.xml

我想为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>

Then i right clicked the project and clicked on maven Install,Here i got a build failed error.It has downloaded the jar files but i am getting the below error.

然后我右键单击该项目并单击maven安装,在这里我有一个构建失败的错误。它已下载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

Can Anyone Help me on This?..

谁可以帮我这个事?..

3 个解决方案

#1


1  

The problem is not caused by the dependency but, as clearly staded in the build log:

问题不是由依赖引起的,而是在构建日志中明显存在:

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

此环境中未提供编译器。也许您运行的是JRE而不是JDK?

To set your JAVA_HOME and make Selenium WebDriver work look here

要设置你的JAVA_HOME并让Selenium WebDriver工作,请看这里

#2


1  

I you are using eclipse IDE Right click on project ->Build Path->Configure Build Path->Libraries

我正在使用eclipse IDE右键单击项目 - >构建路径 - >配置构建路径 - >库

Configure JDK there instead of JRE

在那里配置JDK而不是JRE

#3


0  

Maven is an external tool. Your IDE can call it with the right click and stuff but it is basically external tool. By default it uses your JAVA_HOME variable (which should point to JDK and not to JRE). You can check for example with:

Maven是一个外部工具。您的IDE可以通过右键单击和填充来调用它,但它基本上是外部工具。默认情况下,它使用您的JAVA_HOME变量(应该指向JDK而不是JRE)。您可以查看以下示例:

C:\Users\User>echo %JAVA_HOME%
 Output:   C:\Program Files\Java\jdk1.8.0_152 

You can also use

你也可以使用

mvn -Dmaven.compiler.fork=true -Dmaven.compiler.executable=/path/to/the/javac compile

for compilation with a specific compiler but I guess that's not your problem. Just set your JAVA_HOME properly and you should be fine. Also you can try running command line maven. It will help debugging easier and is basically cleaner way to do it. Maybe the IDE is setting a java version different than the system one. You can check with

用于使用特定编译器进行编译,但我想这不是你的问题。只需正确设置你的JAVA_HOME即可。您也可以尝试运行命令行maven。它将有助于调试更容易,并且基本上更清洁。也许IDE正在设置一个与系统版本不同的java版本。你可以查看

mvn -version

Also you can check if you have JDK or JRE by:

您还可以通过以下方式检查您是否拥有JDK或JRE:

javac -version (this will work if you have JDK)

#1


1  

The problem is not caused by the dependency but, as clearly staded in the build log:

问题不是由依赖引起的,而是在构建日志中明显存在:

No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

此环境中未提供编译器。也许您运行的是JRE而不是JDK?

To set your JAVA_HOME and make Selenium WebDriver work look here

要设置你的JAVA_HOME并让Selenium WebDriver工作,请看这里

#2


1  

I you are using eclipse IDE Right click on project ->Build Path->Configure Build Path->Libraries

我正在使用eclipse IDE右键单击项目 - >构建路径 - >配置构建路径 - >库

Configure JDK there instead of JRE

在那里配置JDK而不是JRE

#3


0  

Maven is an external tool. Your IDE can call it with the right click and stuff but it is basically external tool. By default it uses your JAVA_HOME variable (which should point to JDK and not to JRE). You can check for example with:

Maven是一个外部工具。您的IDE可以通过右键单击和填充来调用它,但它基本上是外部工具。默认情况下,它使用您的JAVA_HOME变量(应该指向JDK而不是JRE)。您可以查看以下示例:

C:\Users\User>echo %JAVA_HOME%
 Output:   C:\Program Files\Java\jdk1.8.0_152 

You can also use

你也可以使用

mvn -Dmaven.compiler.fork=true -Dmaven.compiler.executable=/path/to/the/javac compile

for compilation with a specific compiler but I guess that's not your problem. Just set your JAVA_HOME properly and you should be fine. Also you can try running command line maven. It will help debugging easier and is basically cleaner way to do it. Maybe the IDE is setting a java version different than the system one. You can check with

用于使用特定编译器进行编译,但我想这不是你的问题。只需正确设置你的JAVA_HOME即可。您也可以尝试运行命令行maven。它将有助于调试更容易,并且基本上更清洁。也许IDE正在设置一个与系统版本不同的java版本。你可以查看

mvn -version

Also you can check if you have JDK or JRE by:

您还可以通过以下方式检查您是否拥有JDK或JRE:

javac -version (this will work if you have JDK)