SpringBoot特征:
1. SpringBoot Starter:他将常用的依赖分组进行了整合,将其合并到一个依赖中,这样就可以一次性添加到项目的Maven或Gradle构建中。
2,使编码变得简单,SpringBoot采用 JavaConfig的方式对Spring进行配置,并且提供了大量的注解,极大的提高了工作效率,比如@Configuration和@bean注解结合,基于@Configuration完成类扫描,基于@bean注解把返回值注入IOC容器。
3.自动配置:SpringBoot的自动配置特性利用了Spring对条件化配置的支持,合理地推测应用所需的bean并自动化配置他们。
4.使部署变得简单,SpringBoot内置了三种Servlet容器,Tomcat,Jetty,undertow.我们只需要一个Java的运行环境就可以跑SpringBoot的项目了,SpringBoot的项目可以打成一个jar包。

Springboot开发问题汇总

问题汇总

Lombok requires enabled annotation processing的错误消息

Springboot开发中可能遇到的问题_java

解决办法

Springboot开发中可能遇到的问题_spring_02

springboot 接收datetime-local提交的 日期类型的参数

前端传入

把页面上的intime日期数据,交给后台处理.由于页面的数据都当做String类型处理,所以交给后台处理时,会抛出400错误。需要使用注解进行类型转换。并指定日期格式。

default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'inTime'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.util.Date] for value [2023-07-16]; nested exception is java.lang.IllegalArgumentException]]

解决办法1

        在pojo层封装数据里的日期处,添加日期处理注解

@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm", timezone = "GMT+8") //返回时间类型

@DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm") //接收时间类型

。pattern格式根据提交的Date信息确定。

Springboot开发中可能遇到的问题_mysql_03

在实体类 private Date 日期变量 上添加@DateTimeFormat(pattern=“YYYY-MM-dd”)
在实体类上将import java.util.Date 改为 java.sql.Date

解决办法2

全局配置

Springboot开发中可能遇到的问题_spring_04

spring.jackson.date-format=yyyy-MM-dd HH:mm:ss

服务器重启后mysql数据库无法启动

MySQL server PID file could not be found!                  [FAILED]

Starting MySQL.The server quit without updating PID file (/[FAILED]l/mysql/data/store-mysql5.pid).

Springboot开发中可能遇到的问题_spring boot_05

解决办法

执行

/etc/init.d/mysqld start

/usr/local/mysql/support-files/mysql.server start

打包后访问路径

http://localhost:8080/WMS/web/login.html

Circular view path [test]: would dispatch back to the current handler URL [/boot/test] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified

Springboot开发中可能遇到的问题_java_06

处理办法

Springboot开发中可能遇到的问题_后端_07

或全局

Springboot开发中可能遇到的问题_spring boot_08

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

问题

***************************

APPLICATION FAILED TO START

***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

解决办法

1、方法一

<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.4.1</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</exclusion>
</exclusions>
</dependency>

2、方法二

<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3</version>
<exclusions>
<exclusion>
<artifactId>mybatis-spring</artifactId>
<groupId>org.mybatis</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>3.0.3</version>
</dependency>

3、方法三

升级dynamic-datasource-spring-boot-starter版本至3.6.1或最新版本

错误: 无法验证 dlcdn.apache.org 的由 “/C=US/O=Let‘s Encrypt/CN=R3” 颁发的证书: 颁发的证书已经过期。要以不安全的方式连接至 dlcdn.apa

yum install -y ca-certificates

wget --no-check-certificate https://archive.apache.org/dist/rocketmq/4.9.4/rocketmq-all-4.9.4-bin-release.zip

打包时可能出现的问题maven [INFO] No proxies configured [INFO] No proxy was configured, downloading directly

经过过排查后发现,是少了yarn-v1.22.10

https://github.com/yarnpkg/yarn/releases/download/v1.22.10/yarn-v1.22.10.tar.gz

Bean named 'ddlApplicationRunner' is expected to be of type 'org.springframework.boot.Runner' but was actually of type 'org.springframework.beans.factory.support.NullBean'

解决办法1

Springboot开发中可能遇到的问题_spring boot_09


@Bean public DdlApplicationRunner ddlApplicationRunner(@Autowired(required = false) List ddlList) { return new DdlApplicationRunner(ddlList); }


解决办法2

Spring Boot 的版本号通常采用 X.Y.Z 的形式,其中 X 是主版本号,Y 是次版本号,Z 是修订版本号,为了确保最佳的兼容性和功能性,建议使用相同主版本的Spring Boot和MyBatis Plus。例如,可以考虑使用Spring Boot至3.5.3版本的最新修订版

<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.5.3</version>
    <exclusions>
        <exclusion>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-generator</artifactId>
        </exclusion>
    </exclusions>
</dependency>