针对SpringBoot/Maybatis/MySql的依赖配置(Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only support)

在代码运行过程中,出现了以下报错信息

Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

        这个警告消息是Java HotSpot虚拟机提供的一个警告,说明在共享类的加载过程中遇到了一些限制,解决方法有检查类路径是否正确设置、检查Java版本和配置、移除共享类加载选项等。

  1. 检查类路径是否正确设置:确保没有错误地修改或追加了引导类路径(bootstrap classpath)。可以检查启动脚本或IDE设置,确认类路径的配置是否正确。

  2. 检查Java版本和配置:确保使用的是支持共享类加载的Java版本。不同的Java版本对共享类的支持程度可能有所不同,可以尝试更新到较新的Java版本。

  3. 移除共享类加载选项:如果在运行Java程序时指定了-Xshare:某个选项,尝试将该选项移除。这个选项是用来启用共享类加载的,但是由于警告消息中提到的限制,可能导致共享类加载出现问题。通过移除这个选项,可以关闭共享类加载,并避免出现警告。

        我使用了springboot3.2.2、jdk17、mybatis3.0.3,出现以上报错信息,我的解决方案是直接修改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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.itheima</groupId>
    <artifactId>springboot-mybatis-quickstart</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot-mybatis-quickstart</name>
    <description>springboot-mybatis-quickstart</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <!-- mybatis的起步依赖 -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.2</version>
        </dependency>
        <!-- mysql的驱动包 -->
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <!-- 单元测试的依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter-test</artifactId>
            <version>2.2.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build> 
</project>

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值