总结一下springBoot框架自己容易遗漏的东西
原创
©著作权归作者所有:来自51CTO博客作者Danna123的原创作品,请联系作者获取转载授权,否则将追究法律责任
1.配置依赖的时候,在项目配置上加热部署,热部署就是应用正在运行的时候升级软件,却不需要重新启动应用。配置上之后我们可以直接更改代码而不用重新启动项目
2.比如平时访问项目:localhost:8080/hello2就可以访问,我现在想加入项目名称,ceshi,所以我们需要在application.properties文件中另行配置
server.context-path=/ceshi
然后就能localhost:8080/ceshi/hello2
3.springboot配置指定跳转页面的存放路径和页面的格式信息
spring.thymeleaf.prefix = classpath:/templates/
spring.thymeleaf.suffix=.html
4.整合Mybatis并使用Mybatis-Generator自动生成所需代码
org.mybatis.generator
mybatis-generator-core
1.3.5
配置文件:
在application.properties配置文件,配置数据源并整合mybatis
#数据源
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/first?useUnicode=true&characterEncoding=utf-8
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#整合mybatis
mybatis.mapper-locations=classpath:/mapper/**.xml
我们需要在resources创建一个mapper文件夹,这里我们将mybatis的xml文件放在class:/mapper/下,
5.在springboot的项目中,如果我们修改了前台界面,会发现刷新界面后没有效果,因此需要重启项目,这样太麻烦,配置下吧
1).在配置文件中给thymeleaf添加如下配置:
spring.thymeleaf.cache=false
2).在Intellij Idea按Ctrl+Shift+F9,之后再浏览器中刷新界面,即可显示出对页面的更改信息