0
点赞
收藏
分享

微信扫一扫

springboot常见错误

  • 错误1:运行项目后报如下错误
  • springboot常见错误_spring

  • 解决方案
  • springboot常见错误_maven_02

  • 报错2:​​Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb​
  • 解决方案:在pom.xml中添加如下

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

  • 错误3:​​Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile​
  • 错误原因:环境配置错误,jdk配置不一致
  • 解决方案

# pom.xml
<properties>
<java.version>8</java.version>
</properties>

springboot常见错误_maven_03

  • 右键 > Project Structure
  • springboot常见错误_maven_04


  • springboot常见错误_Spring Boot_05

  • 错误4:​​Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a​
  • 错误原因:idea环境中jdk版本不一致
  • 解决方案
  • springboot常见错误_Spring Boot_06


  • springboot常见错误_Spring Boot_07


  • springboot常见错误_spring_08


  • springboot常见错误_spring_09


  • springboot常见错误_maven_10

  • 错误5:​​导入依赖后依赖报红​

# 解决方案:可将依赖下载到本地后导入项目

  • 错误6:​​spring boot项目中启动按钮变灰,或者在启动类中启动没反应​

解决方案1:取消idea插件中的groovy


解决方案2:spring boot项目启动按钮变灰,maven>install

  • 错误7:​​spring boot项目启动时报错:Application run failed​

错误原因:当我们spring boot项目中引入了MySQL、mybatis等依赖,且yml中配置了数据源等,但业务类中暂时没有使用到,因为spring boot自动注入的特性,启动项目后会报错,解决方案是暂时排除数据源等配置
解决方案:在启动类添加@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})

  • 错误8:​​Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on​

# 解决方案:在pom.xml中添加插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>

  • 错误9:​​SpringBoot打包后的jar,执行报错:没有主清单属性​

# pom.xml中添加如下
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.3.RELEASE</version>
<configuration>
<mainClass>com.hoymin.gmall.gateway.GatewayMain8888</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>



举报

相关推荐

0 条评论