使用Java 1.8进行构建并在Java 1.7中进行部署

时间:2018-06-29 13:26:02

标签: java maven artifactory tls1.2

我们现有的Web应用程序是使用 JDK 1.6 开发的,并使用maven(2.2.1)构建的。内置的构件(war / ear)使用Java 7部署到环境中。

自2018年6月起,旧产品 TLS 1.0&1.1 协议将不再受Maven,JFrog等各种产品支持。任何访问maven或JFrog的客户端都需要使用TLS 1.2。我们正在使用Bamboo for CI,它当前使用JDK 1.6进行构建,并且由于旧式协议,当前所有构建都失败了。使用Java 1.8构建可以解决问题,但是我不确定如果我使用Java 1.8构建(行家)并将工件(war / ear)部署到使用Java 1.7的环境中是否会出现任何问题。任何指针都会有所帮助。

更新-1

我们决定将构建版本添加到Java 1.8,因为当我们尝试使用Java版本1.7.0_80进行构建(Maven)时,出现以下错误:

    [DEBUG] Error transferring file: Received fatal alert: handshake_failure
org.apache.maven.wagon.TransferFailedException: Error transferring file: Received fatal alert: handshake_failure
        at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:143)
        at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)
        at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
        at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
        at org.apache.maven.artifact.manager.DefaultWagonManager.getRemoteFile(DefaultWagonManager.java:546)
        at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:427)
        at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:382)
        at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216)
        at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)
        at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:558)
        at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromRepository(DefaultMavenProjectBuilder.java:251)
        at org.apache.maven.plugin.DefaultPluginManager.checkRequiredMavenVersion(DefaultPluginManager.java:277)
        at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:205)
        at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:184)
        at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(DefaultPluginManager.java:1642)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1540)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.bindPluginToLifecycle(DefaultLifecycleExecutor.java:1503)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.constructLifecycleMappings(DefaultLifecycleExecutor.java:1282)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:534)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
        at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
        at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
        at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1979)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1086)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1301)
        at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
        at org.apache.maven.wagon.providers.http.LightweightHttpWagon.fillInputData(LightweightHttpWagon.java:115)

Java 1.8解决了构建失败的问题,但是我不确定如果将工件(war / ear)部署到使用Java 1.7的环境中会不会出现任何问题

更新-2 如khmarbaise所述,我在我的方案中使用了工具链,以下是详细信息:

MAVEN_JAVA_HOME和JAVA_HOME-JDK 1.8的路径

Maven版本-2.2.1

更新了我的应用程序父pom.xml,使其包含工具链插件,如下所示:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
  <execution>
    <goals>
      <goal>toolchain</goal>
    </goals>
  </execution>
</executions>
<configuration>
  <toolchains>
    <jdk>
      <version>1.6</version>
      <vendor>sun</vendor>
    </jdk>
  </toolchains>
</configuration>

toolchains.xml文件(如下所示)是用于在其中设置工具链安装路径的配置文件。我已将此文件放在/.m2目录中。

 <?xml version="1.0" encoding="UTF8"?>
<toolchains>
  <!-- JDK toolchains -->
  <toolchain>
    <type>jdk</type>
    <provides>
      <version>1.6</version>
      <vendor>sun</vendor>
    </provides>
    <configuration>
      <jdkHome>C:\Program Files\Java\jdk1.6.0_45</jdkHome>
    </configuration>
  </toolchain>
</toolchains>

我已在本地验证构建成功。我需要验证如何将toolchain.xml文件传递给我的Bamboo配置。

有关如何配置工具链的详细信息,请参见https://maven.apache.org/guides/mini/guide-using-toolchains.html

1 个答案:

答案 0 :(得分:0)

正如khmarbaise所提到的,我在我的场景中使用了工具链,以下是详细信息:

MAVEN_JAVA_HOME和JAVA_HOME-JDK 1.8的路径

Maven版本-2.2.1

更新了我的应用程序父pom.xml,使其包含工具链插件,如下所示:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
  <execution>
    <goals>
      <goal>toolchain</goal>
    </goals>
  </execution>
</executions>
<configuration>
  <toolchains>
    <jdk>
      <version>1.6</version>
      <vendor>sun</vendor>
    </jdk>
  </toolchains>
</configuration>

toolchains.xml文件(如下所示)是用于在其中设置工具链安装路径的配置文件。我已将此文件放在/.m2目录中。

<?xml version="1.0" encoding="UTF8"?>
<toolchains>
  <!-- JDK toolchains -->
  <toolchain>
    <type>jdk</type>
    <provides>
      <version>1.6</version>
      <vendor>sun</vendor>
    </provides>
    <configuration>
      <jdkHome>C:\Program Files\Java\jdk1.6.0_45</jdkHome>
    </configuration>
  </toolchain>
</toolchains>

我已在本地验证构建成功。我需要验证如何将toolchain.xml文件传递给我的Bamboo配置。

有关如何配置工具链的详细信息,请参见https://maven.apache.org/guides/mini/guide-using-toolchains.html