我这里有一个小样本应用程序
https://github.com/jimbasilio/SpringBoot
Run Code Online (Sandbox Code Playgroud)
这会在数据库中创建一些简单的数据以及我正在努力的其他一些东西,以便在春季启动时抛出轮胎(旁注:到目前为止,我喜欢弹簧启动!).如果你克隆git repo,你可以访问网址:
http://127.0.0.1:8080/hello/get/1
Run Code Online (Sandbox Code Playgroud)
它将从数据库加载并将hibernate统计信息写入控制台.
我有一个问题,无论是否通过application.properties文件配置hibernate统计信息:
hibernate.generate_statistics=true
Run Code Online (Sandbox Code Playgroud)
当我写出hibernate统计数据时,我没有任何用处.我通过以下方式获取统计数据:
Session session = (Session) this.entityManager.getDelegate();
session.getSessionFactory().getStatistics().logSummary();
HelloEntity entity = helloRepository.findOne(id);
entityManager.flush();
session.getSessionFactory().getStatistics().logSummary();
Run Code Online (Sandbox Code Playgroud)
我的第二条日志消息(刷新后)如下.你可以看到它甚至没有注册被打开的会话.我正在使用spring boot 1.0.1.RELEASE.
的pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.1.RELEASE</version>
</parent>
Run Code Online (Sandbox Code Playgroud)
日志文件:
2014-04-28 20:51:29.415 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000161: Logging statistics....
2014-04-28 20:51:29.416 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000251: Start time: 1398732682476
2014-04-28 20:51:29.416 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000242: Sessions opened: 0
2014-04-28 20:51:29.416 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000241: Sessions closed: 0
2014-04-28 20:51:29.416 …Run Code Online (Sandbox Code Playgroud) 从这个问题可以看出,Spring Security 管理 Spring Boot 的缓存。从 Spring Boot文档中,它展示了如何使用以下命令设置资源缓存:
spring.resources.cache-period= # cache timeouts in headers sent to browser
Run Code Online (Sandbox Code Playgroud)
这cache-period对于 Spring Boot 的所有预定义静态位置(即/css**、/js/**、/images/**)来说非常有用,但我还生成了一个manifest.appcache用于离线下载我的静态资产的文件,并且由于上述所有 Spring Security/Boot 都会使用 manifest.appcache 发送回缓存标头
"method": "GET",
"path": "/manifest.appcache",
"response": {
"X-Application-Context": "application:local,flyway,oracle,kerberos:8080",
"Expires": "Tue, 06 Oct 2015 16:59:39 GMT",
"Cache-Control": "max-age=31556926, must-revalidate",
"status": "304"
}
Run Code Online (Sandbox Code Playgroud)
我想知道如何添加排除项manifest.appcache。无论我的标头如何,IE 和 Chrome 似乎都会对 appcache 进行“正确的操作”,但 FF 似乎在注意到 appcache 发生更改时更加特殊,并且我认为我的缓存标头将其搞砸了。
编辑:我应该从WebMvcAutoConfiguration的源代码中添加它,它显示了如何为资源设置缓存,我只是不确定如何有选择地禁用我的 1 个案例,而不会潜在地破坏 spring boot 在该文件中设置的其余内容。 …