applicationContext.xml 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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="172.25.220.214" /> <!-- ip -->
  20. <property name="port" value="6379" /> <!-- 端口 -->
  21. <property name="password" value="" /><!-- 鉴权密码 -->
  22. <property name="database" value="1" />
  23. <property name="poolConfig" ref="jedisPoolConfig"></property>
  24. </bean>
  25. <!-- redis template definition -->
  26. <bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate" >
  27. <property name="connectionFactory" ref="jedisConnFactory" />
  28. </bean>
  29. <!-- Add new DAOs here -->
  30. <!-- spring-data for mongo-db configuration -->
  31. <!-- factory bean that creates the Mongo instance -->
  32. <bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean">
  33. <property name="host" value="localhost"/>
  34. <property name="port" value="27017"/>
  35. </bean>
  36. <bean id="userCredentials" class="org.springframework.data.authentication.UserCredentials">
  37. <constructor-arg name="username" value="avicmongo" />
  38. <constructor-arg name="password" value="avic.palmnest" />
  39. </bean>
  40. <!-- Define the MongoTemplate which handles connectivity with MongoDB -->
  41. <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
  42. <constructor-arg name="mongo" ref="mongo"/>
  43. <constructor-arg name="databaseName" value="avic"/>
  44. <constructor-arg name="userCredentials" ref="userCredentials" />
  45. </bean>
  46. </beans>