@bean
("datasource"
)public datasource getdatasource()
//註冊jdbctemplate模組物件bean
@bean
("jdbctemplate"
)public jdbctemplate getjdbctemplate
(@autowired datasource datasource)
package com.itheima.config;
import org.apache.commons.pool2.impl.genericobjectpoolconfig;
import org.springframework.beans.factory.annotation.autowired;
import org.springframework.beans.factory.annotation.value;
import org.springframework.context.annotation.bean;
import org.springframework.context.annotation.propertysource;
import org.springframework.data.redis.connection.redisconnectionfactory;
import org.springframework.data.redis.connection.redisstandaloneconfiguration;
import org.springframework.data.redis.connection.jedis.jedisclientconfiguration;
import org.springframework.data.redis.connection.jedis.jedisconnectionfactory;
import org.springframework.data.redis.core.redistemplate;
import org.springframework.data.redis.serializer.redisserializer;
import org.springframework.data.redis.serializer.stringredisserializer;
@propertysource
("redis.properties"
)public
class
redisconfig")
private string hostname;
@value
("$"
)private integer port;
// @value("$")
// private string password;
@value
("$"
)private integer maxactive;
@value
("$"
)private integer minidle;
@value
("$"
)private integer maxidle;
@value
("$"
)private integer maxwait;
/** *
* @param redisconnectionfactory 鏈結工廠
* @return
*/@bean
//配置redistemplate
public redistemplate createredistemplate
(redisconnectionfactory redisconnectionfactory)
/** *
* @param redisstandaloneconfiguration 鏈結資訊
* @param genericobjectpoolconfig 連線池資訊
* @return redisconnectionfactory 鏈結工廠
*/@bean
//配置redis連線工廠
public redisconnectionfactory createredisconnectionfactory
(redisstandaloneconfiguration redisstandaloneconfiguration,
genericobjectpoolconfig genericobjectpoolconfig)
/** *
* @return 儲存連線池資訊
*/@bean
//配置spring提供的redis連線池資訊
public genericobjectpoolconfig creategenericobjectpoolconfig()
/** *
* @return 儲存的鏈結資訊
*/@bean
//配置redis標準連線配置物件 redis單點配置
public redisstandaloneconfiguration createredisstandaloneconfiguration()
}
Spring模板異常
寫了乙個authcontroller的介面,執行至方法結束,本以為成功了,但是spring卻給了乙個模板無法渲染的異常提示。template might not exist or might not be accessible by anyof the configured template res...
Spring 使用Spring建立物件
xmlversion 1.0 encoding utf 8 beans xmlns xmlns xsi xmlns p xsi schemalocation spring beans 4.1.xsd beans 2.編寫domain,dao,service 3.在spring中註冊元件 要sprin...
spring配置檔案模板
hibernate.dialect org.hibernate.dialect.mysql5dialect hibernate.hbm2ddl.auto update hibernate.show sql false hibernate.format sql false hibernate.cach...