我有一个基于 2.1.0.RELEASE 的 spring boot 项目。我想在运行 java1.7 版本的 Weblogic 服务器上运行这个项目。我试图将我的 pom.xml 中的 java 版本更改为 1.7 ,但它不起作用。
当我从我的项目创建一个可执行 jar 时,它仍然将 build_jdk 显示为 1.8,所以我决定切换到 spring boots 旧版本 1.4.0,期望它在 Java 7 上运行。但是,当我再次构建我的项目时,我没有看到任何更改生成的 jar 的清单文件。它仍将 Spring Boot 版本显示为 2.1.0.RELEASE。
任何人都可以就这两件事中的一件提出建议吗?
- 使用 Spring Boot 2.1.0 和 Java 版本 7 构建项目
- 将 spring boot 降级到 1.4.0 并使用 java 7 构建
这是我的 pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>parent-XYZ-package</groupId>
<artifactId>parent-XYZ-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>myProject</artifactId>
<name>myProject</name>
<url>http://maven.apache.org</url>
<properties>
<java.version>1.7</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
<configuration>
<archive>
<mainClass>MyMainClass</mainClass>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
**<dependency>
<groupId>DependentUserProjec</groupId>
<artifactId>DependentUserProject</artifactId>
<version>${project.version}</version>
</dependency>**
<dependency>
<groupId>weblogic</groupId>
<artifactId>wlfullclient</artifactId>
<version>12.1.2.0.0</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
还有一件事要注意,我的 pom.xml 中已经有一个父 pom 因此我通过标签指定我的 springboot 父依赖项。
更新
我在 pom.xml 中指定的哪个 springboot 版本总是使用 Springboot 2.1.1.RELEASE构建我的项目
下面是我生成的清单文件的快照
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: SID
Start-Class: myMainClass **This line is I have edited just to post on this site**
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Spring-Boot-Version: 2.1.1.RELEASE
Created-By: Apache Maven 3.5.3
Build-Jdk: 1.8.0_181
Main-Class: org.springframework.boot.loader.JarLauncher