springboot3后端学习

创建springboot工程

1.New Project -> Spring Initializr

2.Next -> Spring Boot版本选择3.x -> 勾选Spring Web

3.编写Cotroller

4.启动Spring Boot并在浏览器地址栏中输入 localhost:8080/hello查看效果

手动创建springboot工程

1.创建maven工程

file -> Project Structure -> 上边➕ -> new module -> 选择版本号,命名

2.引入依赖 project(一级)标签里

3.提供启动类并新建resources文件夹下application.properties

启动类名字最好与项目名称一致,后面跟着Application

maven环境配置

maven的环境配置问题:出现无法解析插件_maven无法解析插件-CSDN博客

Spring Validation参数校验

JWT令牌

跟敲过程出现的问题:

一、Cannot resolve plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 

这个错误表明Maven在构建项目时无法解析或下载指定的插件org.apache.maven.plugins:maven-compiler-plugin:3.1。Maven在其本地仓库和远程仓库中查找插件,如果找不到,它会报这个错误。

解决方法:

  1. 检查网络连接:确保你的计算机可以连接到Maven中央仓库。

  2. 检查Maven配置:确认settings.xml文件中的仓库配置正确,没有导致连接问题。

  3. 清理本地仓库:有时候本地仓库中的插件可能损坏,尝试运行mvn clean命令清理项目,然后再次构建。

  4. 检查pom.xml:确保<pluginRepositories>配置正确,如果需要的话,可以添加Maven中央仓库或其他公共仓库的地址。

  5. 手动安装插件:如果上述方法都不行,可以尝试从其他来源手动下载maven-compiler-plugin的3.1版本,并使用mvn install:install-file命令安装到本地仓库。

如果你的项目确实需要这个特定版本的插件,而且上述方法都无法解决问题,可能需要考虑是否有其他网络或权限问题导致无法获取。如果项目可以不使用这个特定版本,可以尝试更新pom.xml中的插件版本号到一个可用的版本。

由于我使用的idea是2021版本,不是2022以上,所以不采用new project方式,而是采用new module

二、Could not find artifact org.springframework.boot:spring-boot-stater-web:pom:unknown in alimaven

报错解释:

这个错误表明Maven构建工具在尝试构建一个Spring Boot项目时,无法找到指定的依赖项spring-boot-stater-web。这个依赖项的groupId应该是org.springframework.boot,但是在这个依赖项的名字中存在一个错误,正确的名字应该是spring-boot-starter-web,而不是spring-boot-stater-web(少了一个'r'字母)。

解决方法:

  1. 检查你的项目中的pom.xml文件,找到包含错误依赖的地方。

  2. 更正依赖项的名字,将spring-boot-stater-web改为spring-boot-starter-web

  3. 保存pom.xml文件。

  4. 运行Maven命令(例如mvn clean install)来重新构建项目。

确保你的Maven仓库设置正确,并且你有权访问Maven中央仓库或者任何配置的私有仓库。如果问题依然存在,可能需要检查网络连接或者仓库的配置。

三、Terminated with exit code 1

IDEA报错Terminated with exit code 1最新解决方案-CSDN博客

四、springboot启动失败

初始化项目的时候已经定义一个helloController的方法,basicController中的删除

五、Unresolved plugin: 'org.apache.maven.plugins:maven-clean-plugin:3.2.0'

从以下官网上搜索对应的包下载

https://mvnrepository.com/

六、org.springframework.core.io.support.SpringFactoriesLoader.forDefaultResourceLocation(java.lang.ClassLoader)'

依赖的版本不适配

七、

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

完美解决failed to configure a datasource: ‘url‘ attribute is not specified and no em_failed to configure a datasource: 'url' attribute -CSDN博客

数据库配置问题,yml文件放在resources目录下,我却放在其子目录下了。

八、Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.mybatis.spring.MyBatisSystemException] with root cause

接口调试的响应码为500

解决方法:在controller层中的方法参数前加入@RequestBody注解,之后响应码变为400,但是数据没有写回

请求参数格式选成了form-data,出现以上情况,改成urlencoded格式,出现Data too long for column 'username' at row 1并且响应码又变成500,将@RequestBody注解删掉,成功解决。

九、

JSON parse error: Cannot construct instance of `com.pet.pojo.User` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)",

cannot deserialize from Object value (no delegate- or property-based Creator) 解决方法-CSDN博客

十、Cannot invoke "com.pet.mapper.PetMapper.add(com.pet.pojo.Pet)" because "this.petMapper" is null

添加@Autowired

十一、Could not autowire. No beans of 'StringRedisTemplate' type found.

使用@Autowir自动装配StringRedisTemplate报错Could not autowire. No beans of ‘StringRedisTemplate‘ type found._could not autowire. no beans of 'stringredistempla-CSDN博客 

  • 22
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值