简体   繁体   English

带有Maven-surefire-plugin的UnsatisfiedLinkError

[英]UnsatisfiedLinkError with maven-surefire-plugin

When running a unit test with the maven-surefire-plugin , this error occures: 使用maven- surefire -plugin运行单元测试时,会发生以下错误:

java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM java.lang.UnsatisfiedLinkError:无法在64位JVM上加载32位SWT库

I know how to cope with this problem in my IDE, I simply have to select the correct runtime JRE in the test's run configuration. 我知道如何在IDE中解决此问题,我只需要在测试的运行配置中选择正确的运行时JRE。 However, when the test is run on a TeamCity build server, the error mentioned above occurs. 但是,在TeamCity构建服务器上运行测试时,会发生上述错误。

Is there any surefire or TeamCity option to configure the runtime JRE? 是否有任何surefire或TeamCity选项来配置运行时JRE?

This is my current surefire configuration: 这是我当前的surefire配置:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <skipTests>false</skipTests>
    <includes>
      <include>**/*Test.java</include>
    </includes>
    <parallel>methods</parallel>
    <threadCount>10</threadCount>
  </configuration>
</plugin>

You can use the jvm tag to specify which JVM to use : 您可以使用jvm标记来指定要使用的JVM:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <jvm>${env.MY_JAVA_HOME}/bin/java</jvm>
        <skipTests>false</skipTests>
        <includes>
            <include>**/*Test.java</include>
        </includes>
        <parallel>methods</parallel>
        <threadCount>10</threadCount>
    </configuration>
</plugin>

This example assumes that you have a MY_JAVA_HOME environment variable. 本示例假定您具有MY_JAVA_HOME环境变量。

When configuring a Maven build step in TeamCity , select a target JDK with the appropriate "bitness" (x86 in your case): TeamCity中配置Maven构建步骤时,请选择具有适当“位数”(在您的情况下为x86)的目标JDK:

在此处输入图片说明

At least one of your build agents should have a 32-bit JDK discovered and available. 您的构建代理程序中至少应有一个已发现并可用的32位JDK。 You can check whether this is the case for a particular agent by Agents -> Connected -> -> Agent Parameters -> Environment Variables. 您可以通过代理->已连接->->代理参数->环境变量来检查特定代理是否属于这种情况。 Here's an example of JDK_* variables with their values: 这是JDK_*变量及其值的示例:

JDK_14       C:\Program Files (x86)\Java\jdk1.4.2_19
JDK_15       C:\Program Files\Java\jdk1.5.0_22
JDK_15_x64   C:\Program Files\Java\jdk1.5.0_22
JDK_16       C:\Program Files (x86)\Java\jdk1.6.0_45
JDK_16_x64   C:\Program Files\Java\jdk1.6.0_45
JDK_17       C:\Program Files (x86)\Java\jdk1.7.0_76
JDK_17_x64   C:\Program Files\Java\jdk1.7.0_76
JDK_18       C:\Program Files\Java\jdk1.8.0_40
JDK_18_x64   C:\Program Files\Java\jdk1.8.0_40

Here, JDK_18 and JDK_18_x64 having the same value means that the agent hasn't found a 32-bit 1.8 JDK. 在此,具有相同值的JDK_18JDK_18_x64表示该代理尚未找到32位1.8 JDK。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM