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后面少了个冒号,也是够坑的。提醒下自己,找不到配置问题时不妨看看拼写错误!