我使用Maven项目在服务器上的Jenkins中运行我的测试。
服务器上java的默认路径是 / usr / lib中/ JVM / java的的openjdk / bin中/ JAVA
相反,我想在我的测试中使用java 1.8,它位于:
/usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
如何在jenkins属性或POM文件中设置它,以便maven将使用java 1.8而不是默认值?
我尝试设置一个String属性JAVA_HOME或者在MAVEN_OPTS中设置jdk 8的路径,但它仍然使用默认的java。
答案 0 :(得分:2)
答案 1 :(得分:1)
的pom.xml:
if ( $stmt3 = $mysqli->prepare("INSERT INTO tbluser (username, password,email,role) SELECT companyUsername,companyPassword,companyEmail, 1 FROM tblpartner WHERE companyId=?" )) {
$stmt3->bind_param('i', $id);
$stmt3->execute();
}
激活个人资料jdk8:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>${jdk}/bin/javac</executable>
<compilerVersion>1.5</compilerVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<jvm>${jdk}/bin/java</jvm>
<forkMode>once</forkMode>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>default_jdk</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<jdk>${env.JAVA_HOME}</jdk>
</properties>
</profile>
<profile>
<id>jdk8</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<jdk>/usr/lib/jvm/jre-1.8.0-openjdk.x86_64</jdk>
</properties>
</profile>
</profiles>