maven使用时候出现,jdk1.5的情况的解决办法

目录

出现错误

​编辑 

形式

作用

步骤

1.修改在pom.xml中即可 

2.改成对应的版本​编辑


出现错误

形式

 <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

作用

pom.xml中的maven.compiler.source和maven.compiler.是用来编译源码和打包的,通常它们的版本等于系统JDK的大版本,如11,9,8...;

如果不能控制客户机的jdk,而想让包的适用性更广的话,可以手动降低版本号,比如如从11降到8;

如此做了后,在别的机器上运行自己的jar,就不会爆jdk版本低的错误。

举例来说,我之前使用11打了个jar包,放到jdk=9的虚拟机上没法用,于是手动降低到8,因为代码中也确实没用到8后继版本的特性,于是再次打包后,虚拟机上再运行就可以了。

步骤

1.修改在pom.xml中即可 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>JsonPretty</artifactId>
    <version>1.00</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>2.6.4</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>5.3.16</version>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

2.改成对应的版本

 

 

 

将版本都改成对应的就可以运行了,一般jdk出现1.5错误,无法install,只需要在模块的pom.xml中加入 

<properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>  

然后修改各个版本对应即可

即可install

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值