Springboot开发中可能遇到的问题

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 接收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信息确定。


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

解决办法2

全局配置

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).

解决办法

执行

/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

处理办法

或全局

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、方法二

 
  1. <dependency>

  2. <groupId>com.baomidou</groupId>

  3. <artifactId>mybatis-plus-boot-starter</artifactId>

  4. <version>3.5.3</version>

  5. <exclusions>

  6. <exclusion>

  7. <artifactId>mybatis-spring</artifactId>

  8. <groupId>org.mybatis</groupId>

  9. </exclusion>

  10. </exclusions>

  11. </dependency>

  12. <dependency>

  13. <groupId>org.mybatis</groupId>

  14. <artifactId>mybatis-spring</artifactId>

  15. <version>3.0.3</version>

  16. </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

@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>

新建Spring Initializr项目只有是17和21问题的解决方法

新建Spring Initializr项目时,选择java版本只有是17和21


将https://start.spring.io修改为阿里云的路径:https://start.aliyun.com

  • 29
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

QGS-CD

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值