springboot启动类报错 求解?
报错信息:Cannot resolve method 'run(java.lang.Class, String[])'
使用工具:IDEA
问题复盘:
使用springboot的initialzer创建的父子项目工程
PS:我这个版本新建父项目的时候没有type选项选择maven Pom 只有maven和gradle选项,由于spring.io请求不上就只能用springboot.io作为server URL 下面配图
父工程通过这种方式创建之后我把src删除 并且在Pom文件设置了<packaging>pom</packaging>
parent标签在通过initialzer创建module的时候已经自动去starter继承依赖,下面附上Pom文件以及项目的结构
//父文件的pom配置<?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.4.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<packaging>pom</packaging>
<groupId>com.example</groupId>
<artifactId>springboot_parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot_parent</name>
<description>springboot_parent</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
接下来附上子项目的pom配置,已经在parent中继承了父项目的依赖
<?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>com.example</groupId>
<artifactId>springboot_parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.example</groupId>
<artifactId>spirng_initialzer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spirng_initialzer</name>
<description>spirng_initialzer</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
通过搜索报错我已经尝试过通过清除cache 重启项目 但是还是报错,并且确保了jdk可用,并且在structure下并没有看到报错的包
!!!求大佬们给我一点建议,遇到过此问题的大佬麻烦给一个解决方案
以上是 springboot启动类报错 求解? 的全部内容, 来源链接: utcz.com/p/944513.html