idea创建springboot中所遇到的坑?你遇到了这些了吗?
文章目录
在创建Spring Boot项目时,默认采用Maven构建模式。
问题一:每次启动都会自动下载Maven所需的依赖项。
问题二:遇到编码错误时发现服务器时间区值为'�й���ʱ��' ,该值未被识别或对应多个时间区。
问题三:集成Freemaker与Spring Boot可能遇到的关键挑战。
问题四:发现端口已被占用导致无法访问组件[Connector[HTTP/1.1-8880]]。
问题五:使用Maven的package命令生成的jar文件出现读取异常。
问题六:要查看条件报告需确保应用已启用调试模式。
- 总结:入坑不断问题不断,在这里找到你的解决方法,是我的一大满足
创建springboot项目使用的是MAVEN模式
问题一、每次创建都会自动下载maven所需的依赖包
解决方法:
file–》other settings–》settings for new project

Maven的项目根目录:你的maven安装路径
用户的配置文件:maven安装路径下的conf – 设置文件的位置
本地仓库:所需的JAR文件存储在中央仓库中
完成勾选后,启动Spring Boot服务将不再自动下载Maven库,并且只会导入尚未存在的JAR文件。
The server's timezone value '�й���ʱ���' is invalid or does not correspond to a single timezone.
解决方法:
在配置文件中进行 url 配置 spring.datasource.url=jdbc:mysql://localhost:3306/trainning?characterEncoding=utf-8&&serverTimezone=UTC
server.port = 8889
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/trainning?characterEncoding=utf-8&&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=xxxxx
mybatis.mapper-locations=classpath:mapper/*.xml
代码解读
问题三、springboot+freemaker综合的坑
一、无妨访问
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Apr 29 21:30:08 CST 2020
There was an unexpected error (type=Not Found, status=404).
No message available
代码解读
解决方法:
查看pom文件中的依赖,
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
代码解读
在templates文件夹下无法生成***.ftl**文件的具体操作流程如下:1. 在菜单栏中选择【File

添加一个***.ftl**的文件格式
问题四、端口号被占用导致无法访问的问题(Failed to start component [Connector[HTTP/1.1-8880]])
解决方法:调用命令提示符(在开始菜单中找到快捷方式 windows+r)运行命令CMD以获取已使用的端口号信息

随后启动任务管理器,并进入详细信息设置。通过dos窗口显示的端口号查找对应的任务进程,并将该进程终止。问题得到解决
利用 Maven构建工具生成的JAR文件(无法访问预览文件:xxx.jar)
解决方法:
- 可能与路径设置有关,请尝试使用绝对路径来解决问题。
- 配置文件可能存在相关问题,请检查并确认自己配置的文件是否正确,并避免直接复制粘贴以防止潜在问题。
To present the conditions report, re-run your application with 'debug' enabled.
Description:
A component required a bean of type 'com.project01.project01.dao.UserDao' that could not be found.
Action:
Consider defining a bean of type 'com.project01.project01.dao.UserDao' in your configuration.
代码解读
在扫描过程中无法识别到userdao接口

就可以解决这个问题
