从属性文件将Integer传递给@EnableJdbcHttpSession

问题描述 投票:0回答:1

如何将application.yml文件中的Integer参数传递给@EnableJdbcHttpSession注释属性?它的工作原理如下:

@EnableJdbcHttpSession(tableName = "${some.string.property}")

但如果这样写的话会显示意外类型:

@EnableJdbcHttpSession(maxInactiveIntervalInSeconds = "${some.Integer.property}")
spring-session
1个回答
0
投票

只有tableName@EnableJdbcHttpSession属性支持占位符分辨率(请参阅related JdbcHttpSessionConfiguration code)。

但是既然你提到application.yml,如果你正在使用Spring Boot,你可以简单地省略@EnableJdbcHttpSession并让Spring Boot自动配置Spring Session。此时,您可以使用以下属性轻松自定义Spring Session JDBC:

spring.session.jdbc.cleanup-cron=0 * * * * * # Cron expression for expired session cleanup job.
spring.session.jdbc.initialize-schema=embedded # Database schema initialization mode.
spring.session.jdbc.schema=classpath:org/springframework/session/jdbc/schema-@@platform@@.sql # Path to the SQL file to use to initialize the database schema.
spring.session.jdbc.table-name=SPRING_SESSION # Name of the database table used to store sessions.

有关详细信息,请参阅Spring Boot的reference manual

© www.soinside.com 2019 - 2024. All rights reserved.