java:无法访问org.springframework.boot.SpringApplication的解决方法

作者:极客李华 时间:2022-07-14 05:24:29 

报错信息如下:

java: 无法访问org.springframework.boot.SpringApplication
错误的类文件: /C:/Users/11848/.m2/repository/org/springframework/boot/spring-boot/3.0.0/spring-boot-3.0.0.jar!/org/springframework/boot/SpringApplication.class
类文件具有错误的版本 61.0, 应为 52.0
请删除该文件或确保该文件位于正确的类路径子目录中。

解决办法:

这个错误的原因是idea默认的spring-boot-starter-parent版本是3.0,改成2.7.6或者更低版本就可以了

java:无法访问org.springframework.boot.SpringApplication的解决方法

java:无法访问org.springframework.boot.SpringApplication的解决方法

合并集合

一共有 n 个数,编号是 1∼n,最开始每个数各自在一个集合中。

现在要进行 m 个操作,操作共有两种:

M a b,将编号为 a 和 b 的两个数所在的集合合并,如果两个数已经在同一个集合中,则忽略这个操作;

Q a b,询问编号为 a 和 b 的两个数是否在同一个集合中;

输入格式

第一行输入整数 n 和 m。

接下来 m 行,每行包含一个操作指令,指令为 M a b 或 Q a b 中的一种。

输出格式

对于每个询问指令 Q a b,都要输出一个结果,如果 a 和 b 在同一集合内,则输出 Yes,否则输出 No。

每个结果占一行。

数据范围

1≤n,m≤105

输入样例:

4 5
M 1 2
M 3 4
Q 1 2
Q 1 3
Q 3 4

输出样例:

Yes
No
Yes

提交代码

#include<iostream>
using namespace std;

const int N = 100010;
int n, m;
int p[N];

int find(int x)                 // 找到x的祖先节点
{
   if (p[x] != x) p[x] = find(p[x]);
   return p[x];
}

int main()
{
   scanf("%d %d", &n, &m);
   for (int i = 1; i <= n; ++i) p[i] = i;

while (m--)
   {
       char op;
       int a, b;
       scanf (" %c%d%d", &op, &a, &b);
       if (op == 'M') p[p[find(a)]] = find(b);        // 让a的祖先节点指向b的祖先节点
       else
       {
           if (find(a) == find(b)) puts("Yes");
           else puts("No");
       }
   }
   return 0;
}
import java.io.*;

public class Main
{
   static int N = 100010;
   static int n, m;
   static int [] p = new int [N];

static int find(int x)
   {
       if (p[x] != x) p[x] = find(p[x]);
       return p[x];
   }

public static void main(String[] args) throws IOException
   {
       BufferedReader reader = new BufferedReader(new InputStreamReader (System.in));  
       String [] str = reader.readLine().split(" ");
       n = Integer.parseInt(str[0]);
       m = Integer.parseInt(str[1]);

for (int i = 1; i <= n; ++ i) p[i] = i;
       while (m -- > 0)
       {
           String op;
           int a, b;
           str = reader.readLine().split(" ");
           op = str[0];
           a = Integer.parseInt(str[1]);
           b = Integer.parseInt(str[2]);
           if (op.equals("M")) p[find(a)] = find(b);
           else
           {
               if (find(a) == find(b)) System.out.println("Yes");
               else System.out.println("No");
           }
       }
   }
}

来源:https://blog.csdn.net/qq_51447496/article/details/128279192

标签:java,无法访问,org.springframework
0
投稿

猜你喜欢

  • MyBatis自定义映射关系和关联查询实现方法详解

    2021-12-18 21:25:28
  • 详解关于SpringBoot的外部化配置使用记录

    2023-08-10 03:54:54
  • 线程池中execute与submit的区别说明

    2023-03-18 23:09:04
  • 利用Spring boot如何创建简单的web交互应用

    2023-07-15 12:47:00
  • Java中用enum结合testng实现数据驱动的方法示例

    2021-08-04 07:44:21
  • Mybatis Log Plugin的使用方式

    2021-08-27 19:02:31
  • Springboot Vue可配置调度任务实现示例详解

    2023-11-09 03:33:19
  • 详解spring-boot集成elasticsearch及其简单应用

    2021-08-26 01:09:58
  • 老生常谈java中cookie的使用

    2023-11-11 04:37:59
  • java基础的详细了解第七天

    2023-02-01 12:06:26
  • Java快速掌握Vector类方法

    2023-11-24 22:49:18
  • Springboot与vue实现数据导出方法具体介绍

    2023-11-06 21:00:34
  • Java 中的垃圾回收机制详解

    2023-01-11 19:32:34
  • 一次由Lombok的@AllArgsConstructor注解引发的错误及解决

    2023-10-07 05:23:42
  • SpringBoot JS-SDK自定义微信分享的实现

    2023-11-10 05:08:28
  • Mybatis实现SQL存储流程详解

    2022-09-11 05:17:05
  • Mybatis中 mapper-locations和@MapperScan的作用

    2023-07-13 08:08:34
  • Spring maven filtering使用方法详解

    2021-07-02 22:14:46
  • Java 反射机制实例详解

    2023-11-28 03:49:47
  • Springboot整合微信支付(订单过期取消及商户主动查单)

    2023-05-15 23:40:50
  • asp之家 软件编程 m.aspxhome.com