applicationContext.xml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xmlns:context="http://www.springframework.org/schema/context"
  4. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  5. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
  6. default-lazy-init="true">
  7. <!-- Activates scanning of @Autowired -->
  8. <context:annotation-config/>
  9. <!-- Activates scanning of @Repository and @Service -->
  10. <context:component-scan base-package="com.palmnest"/>
  11. <!-- jedis pool配置 -->
  12. <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
  13. <property name="maxTotal" value="1000"/> <!-- 控制一个pool可分配多少个jedis实例 -->
  14. <property name="maxIdle" value="200" /> <!-- 控制一个pool最多有多少个状态为idle(空闲)的jedis实例 -->
  15. <property name="maxWaitMillis" value="2000" /> <!-- 表示当borrow一个jedis实例时,最大的等待时间,如果超过等待时间,则直接抛出JedisConnectionException -->
  16. <property name="testOnBorrow" value="true" /> <!-- 在borrow一个jedis实例时,是否提前进行validate操作;如果为true,则得到的jedis实例均是可用的 -->
  17. </bean>
  18. <bean id="jedisConnFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory" >
  19. <property name="hostName" value="127.0.0.1" /> <!-- ip -->
  20. <property name="port" value="6379" /> <!-- 端口 -->
  21. <property name="password" value="123.com.cn" /><!-- 鉴权密码 -->
  22. <property name="poolConfig" ref="jedisPoolConfig"></property>
  23. </bean>
  24. <!-- redis template definition -->
  25. <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" >
  26. <property name="connectionFactory" ref="jedisConnFactory" />
  27. </bean>
  28. <!-- Add new DAOs here -->
  29. <!-- spring-data for mongo-db configuration -->
  30. <!-- factory bean that creates the Mongo instance -->
  31. <bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean">
  32. <property name="host" value="localhost"/>
  33. <property name="port" value="27017"/>
  34. </bean>
  35. <bean id="userCredentials" class="org.springframework.data.authentication.UserCredentials">
  36. <constructor-arg name="username" value="avicmongo" />
  37. <constructor-arg name="password" value="avic.palmnest" />
  38. </bean>
  39. <!-- Define the MongoTemplate which handles connectivity with MongoDB -->
  40. <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
  41. <constructor-arg name="mongo" ref="mongo"/>
  42. <constructor-arg name="databaseName" value="avic"/>
  43. <constructor-arg name="userCredentials" ref="userCredentials" />
  44. </bean>
  45. </beans>