简体   繁体   English

如何降级spring引导项目?

[英]how to downgrade spring boot project?

I have a spring boot project build on 2.1.0.RELEASE .我在 2.1.0.RELEASE 上构建了一个2.1.0.RELEASE引导项目。 I want to run this project on Weblogic server which is running on a java1.7 version.我想在运行java1.7版本的Weblogic服务器上运行这个项目。 I tried to change the java version in my pom.xml to <java.version>1.7</java.version> but it didn't work.我试图将我的pom.xml中的 java 版本更改为<java.version>1.7</java.version>但它没有用。

when I create an executable jar from my project it still showing build_jdk as 1.8 so I decided to switch to springboot's older version 1.4.0 expecting it to run on Java 7. However, when I build my project again I don't see any change in the manifest file of the generated jar. It is still showing springboot version as 2.1.0.RELEASE .当我从我的项目创建一个可执行文件 jar 时它仍然显示 build_jdk 为 1.8 所以我决定切换到springboot 的旧版本 1.4.0 期望它在 Java 上运行 7. 但是,当我再次构建我的项目时我没有看到任何变化在生成的 jar 的清单文件中。它仍然显示springboot版本为2.1.0.RELEASE

can anyone suggest regarding one of the 2 things?任何人都可以就这两件事之一提出建议吗?

  1. Build project with springboot 2.1.0 and Java version 7使用springboot 2.1.0 和 Java 版本 7 构建项目
  2. Downgrade springboot to 1.4.0 and build with Java 7springboot降级到 1.4.0 并使用 Java 7 构建

here is my pom.xml这是我的 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>

one more thing to note that I already have a parent pom in my pom.xml Hence I am specifying my springboot parent dependency through <DependencyManagement> tag.还有一件事要注意,我的pom.xml中已经有一个父 pom,因此我通过<DependencyManagement>标记指定我的springboot父依赖项。

Update更新

Which ever springboot version I specify in pom.xml its always building my project with Springboot 2.1.1.RELEASE我在 pom.xml 中指定的哪个springboot版本总是使用Springboot 2.1.1.RELEASE构建我的项目

Below is the snapshot from my manifest file generated下面是我生成的清单文件的快照

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

step 1 : change the java version in pom file .第 1 步:更改pom file中的 java 版本。

<properties>
    <java.version>1.8</java.version>
</properties>

step 2 : Go to maven and update the project.第 2 步:Go 到 maven 并更新项目。

Go to maven and update the project Go 到 maven 并更新项目

More Details on this video有关此视频的更多详细信息

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

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