Spring Boot 学习笔记(一)

2017.11.16

Spring Boot中@Configuration标签相当于<Beans>标签,@Bean相当于<Bean>标签,这两个标签将一个类封装为Bean,将类的生命周期交给SpringBoot管理。例如集成Shiro和Redis框架时需要用到该技术。


2017.11.18

Beetl配置步骤

(1)pom中引用:

<dependency>
   <groupId>com.ibeetl</groupId>
   <artifactId>beetl-framework-starter</artifactId>
   <version>1.1.12.RELEASE</version>
</dependency>

(2)yml文件配置

beetl:
  root: /WEB-INF/templates/  此处配置默认的根路径
  charset: UTF-8
  prefix:
  suffix: .html
  config: classpath:beetl.properties   用beetl.properties文件代替默认的beetl.properties文件
(3)正式开始配置Beetl

创建BeetlConfig Bean主要利用BeetlGroupUtilConfiguration类配置webAppResourceLoader的路劲如下

WebAppResourceLoader webAppResourceLoader = new WebAppResourceLoader(patternResolver.getResource("classpath:/templates").getFile().getPath());

上述语句默认到src/main/java/resources文件夹下寻找templates文件夹,并装配其中的html页面。

(4)配置Beetl的页面解析器

public BeetlSpringViewResolver getBeetlSpringViewResolver(@Qualifier("beetlConfig") BeetlGroupUtilConfiguration beetlGroupUtilConfiguration) {
    BeetlSpringViewResolver beetlSpringViewResolver = new BeetlSpringViewResolver();
    beetlSpringViewResolver.setPrefix("/");
    beetlSpringViewResolver.setSuffix(".html");
    beetlSpringViewResolver.setContentType("text/html;charset=UTF-8");
    beetlSpringViewResolver.setOrder(0);
    beetlSpringViewResolver.setConfig(beetlGroupUtilConfiguration);
    return beetlSpringViewResolver;

至此就配置完成可以在前台使用Beetl引擎的html页面了

2017.11.20

问题解决,Beetl配置完成后,使用Shiro进行用户认证时一直出现,jdbc Driver return null for Url的情况,百思不得其解,反复确认pom引用、Spirng jdbc的配置还是没有找到错误,知道看到stack over上一个类似的问题后终于解答,我的application.yml文件中的
url: jdbc:mysql://localhost:3306/shirotestdb
这一项被我写错了,我直接写了jdbc:mysql//localhost:3306/shirotestdb,mysql后面少了个冒号,也是够坑的。提醒下自己,找不到配置问题时不妨看看拼写错误!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值