初学spring boot;第一次创建好spring boot的项目,开始想跑起来时,有两个问题?(在https://start.spring.io/快速创建时,一般会遇到)

1、dataSource的url...是因为 在application.properties没有配置数据库连接资源。

通常有两个方法解决:a.在application.properties文件中配置数据库资源

spring.datasource.url=jdbc:mysql://localhost:3306/xxxx?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.hikari.login-timeout=1000
spring.datasource.hikari.maximum-pool-size=30

b.添加注解,额,注解忘了。

2、启动没问题后,http://localhost:8080/login 发现需要认证登录,是因为在spring boot项目pom.xml中默认引入依赖

<dependency>
   <groupId>org.springframework.security</groupId>
   <artifactId>spring-security-test</artifactId>
   <scope>test</scope>
</dependency>

一般解决方法有两种:a.把这个依赖注释掉。b.可以在IDEA控制台看到登录密码,但是username却是default,直接复制过去发现不行,其实密码是没错,直接从控制台把密码复制过去,username其实默认是“user”,到这里就可以登陆完成了,进行接下来的学习了。

3、写个测试类,MyTest

这时在http://localhost:8080/MyTest/hello就可以看到返回的数据了

猜你喜欢

转载自blog.csdn.net/linji_nice/article/details/83214691