Commit 523164127d6eb3c6e4a9112597e87c2aefbe64b9
1 parent
77cd98b9ec
Exists in
master
and in
1 other branch
增加配置
Showing 4 changed files with 107 additions and 49 deletions
platform-operate-api/src/main/resources/spring/spring-mongodb-old.xml
View file @
5231641
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<beans xmlns="http://www.springframework.org/schema/beans" | |
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mongo="http://www.springframework.org/schema/data/mongo" | |
| 4 | + xsi:schemaLocation="http://www.springframework.org/schema/data/mongo | |
| 5 | + http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd | |
| 6 | + http://www.springframework.org/schema/beans | |
| 7 | + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> | |
| 8 | + | |
| 9 | + <mongo:db-factory id="mongoDbFactory" host="${mongo.db.host}" | |
| 10 | + port="${mongo.db.port}" dbname="${mongo.db.dbname}" /> | |
| 11 | + | |
| 12 | + <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> | |
| 13 | + <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /> | |
| 14 | + <!-- <constructor-arg name="userCredentials" ref="userCredentials"/> --> | |
| 15 | + <constructor-arg name="mongoConverter" ref="mappingMongoConverter" /> | |
| 16 | + </bean> | |
| 17 | + | |
| 18 | + <mongo:mapping-converter base-package="com.lyms.platform.pojo" /> | |
| 19 | + <bean id="mappingContext" class="org.springframework.data.mongodb.core.mapping.MongoMappingContext" /> | |
| 20 | + <!-- 配置mongodb映射类型 --> | |
| 21 | + <bean id="mappingMongoConverter" class="org.springframework.data.mongodb.core.convert.MappingMongoConverter"> | |
| 22 | + <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /> | |
| 23 | + <constructor-arg name="mappingContext" ref="mappingContext" /> | |
| 24 | + <property name="typeMapper" ref="defaultMongoTypeMapper" /> | |
| 25 | + </bean> | |
| 26 | + | |
| 27 | + <!-- 默认Mongodb类型映射 --> | |
| 28 | + <bean id="defaultMongoTypeMapper" class="org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper"> | |
| 29 | + <constructor-arg name="typeKey"> | |
| 30 | + <null /><!-- 这里设置为空,可以把 spring data mongodb 多余保存的_class字段去掉 --> | |
| 31 | + </constructor-arg> | |
| 32 | + </bean> | |
| 33 | + <!-- | |
| 34 | + <bean id="userCredentials" class="org.springframework.data.authentication.UserCredentials"> | |
| 35 | + <description>认证口令</description> | |
| 36 | + <constructor-arg name="username" value="${${mongo.username}}" /> | |
| 37 | + <constructor-arg name="password" value="${${mongo.password}}" /> | |
| 38 | + </bean> | |
| 39 | + | |
| 40 | + <mongo:mongo id="mongo" host="${${mongo.host}}" port="${${mongo.port}}"> | |
| 41 | + | |
| 42 | + <mongo:options connections-per-host="${${mongo.connectionsPerHost}}" | |
| 43 | + | |
| 44 | + threads-allowed-to-block-for-connection-multiplier="${${mongo.threadsAllowedToBlockForConnectionMultiplier}}" | |
| 45 | + | |
| 46 | + connect-timeout="${${mongo.connectTimeout}}" max-wait-time="${${mongo.maxWaitTime}}" | |
| 47 | + | |
| 48 | + auto-connect-retry="${${mongo.autoConnectRetry}}" socket-keep-alive="${${mongo.socketKeepAlive}}" | |
| 49 | + | |
| 50 | + socket-timeout="${${mongo.socketTimeout}}" slave-ok="${${mongo.slaveOk}}" | |
| 51 | + | |
| 52 | + write-number="1" write-timeout="0" write-fsync="true" /> | |
| 53 | + </mongo:mongo>--> | |
| 54 | +</beans> |
platform-operate-api/src/main/resources/spring/spring-mongodb.xml
View file @
5231641
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | 2 | <beans xmlns="http://www.springframework.org/schema/beans" |
| 3 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mongo="http://www.springframework.org/schema/data/mongo" | |
| 4 | - xsi:schemaLocation="http://www.springframework.org/schema/data/mongo | |
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 4 | + xmlns:mongo="http://www.springframework.org/schema/data/mongo" | |
| 5 | + xsi:schemaLocation="http://www.springframework.org/schema/data/mongo | |
| 5 | 6 | http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd |
| 6 | 7 | http://www.springframework.org/schema/beans |
| 7 | 8 | http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> |
| 8 | 9 | |
| 9 | - <mongo:db-factory id="mongoDbFactory" host="${mongo.db.host}" | |
| 10 | - port="${mongo.db.port}" dbname="${mongo.db.dbname}" /> | |
| 10 | + <bean name="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> | |
| 11 | + <constructor-arg name="mongo" ref="mongo"/> | |
| 12 | + <constructor-arg name="userCredentials" ref="userCredentials"/> | |
| 13 | + <constructor-arg name="databaseName" value="platform"/> | |
| 14 | + </bean> | |
| 11 | 15 | |
| 12 | - <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> | |
| 13 | - <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /> | |
| 14 | - <!-- <constructor-arg name="userCredentials" ref="userCredentials"/> --> | |
| 15 | - <constructor-arg name="mongoConverter" ref="mappingMongoConverter" /> | |
| 16 | - </bean> | |
| 17 | 16 | |
| 18 | - <mongo:mapping-converter base-package="com.lyms.platform.pojo" /> | |
| 19 | - <bean id="mappingContext" class="org.springframework.data.mongodb.core.mapping.MongoMappingContext" /> | |
| 20 | - <!-- 配置mongodb映射类型 --> | |
| 21 | - <bean id="mappingMongoConverter" class="org.springframework.data.mongodb.core.convert.MappingMongoConverter"> | |
| 22 | - <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /> | |
| 23 | - <constructor-arg name="mappingContext" ref="mappingContext" /> | |
| 24 | - <property name="typeMapper" ref="defaultMongoTypeMapper" /> | |
| 25 | - </bean> | |
| 17 | + <bean id="defaultMongoTypeMapper" | |
| 18 | + class="org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper"> | |
| 19 | + <constructor-arg name="typeKey"> | |
| 20 | + <null/> | |
| 21 | + </constructor-arg> | |
| 22 | + </bean> | |
| 26 | 23 | |
| 27 | - <!-- 默认Mongodb类型映射 --> | |
| 28 | - <bean id="defaultMongoTypeMapper" class="org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper"> | |
| 29 | - <constructor-arg name="typeKey"> | |
| 30 | - <null /><!-- 这里设置为空,可以把 spring data mongodb 多余保存的_class字段去掉 --> | |
| 31 | - </constructor-arg> | |
| 32 | - </bean> | |
| 33 | - <!-- | |
| 34 | - <bean id="userCredentials" class="org.springframework.data.authentication.UserCredentials"> | |
| 35 | - <description>认证口令</description> | |
| 36 | - <constructor-arg name="username" value="${${mongo.username}}" /> | |
| 37 | - <constructor-arg name="password" value="${${mongo.password}}" /> | |
| 38 | - </bean> | |
| 24 | + <bean id="userCredentials" class="org.springframework.data.authentication.UserCredentials"> | |
| 25 | + <constructor-arg name="username" value="${mongo.db.username}"/> | |
| 26 | + <constructor-arg name="password" value="${mongo.db.password}"/> | |
| 27 | + </bean> | |
| 39 | 28 | |
| 40 | - <mongo:mongo id="mongo" host="${${mongo.host}}" port="${${mongo.port}}"> | |
| 29 | + <mongo:db-factory mongo-ref="mongo" id="mongoDbFactory"/> | |
| 41 | 30 | |
| 42 | - <mongo:options connections-per-host="${${mongo.connectionsPerHost}}" | |
| 43 | - | |
| 44 | - threads-allowed-to-block-for-connection-multiplier="${${mongo.threadsAllowedToBlockForConnectionMultiplier}}" | |
| 45 | - | |
| 46 | - connect-timeout="${${mongo.connectTimeout}}" max-wait-time="${${mongo.maxWaitTime}}" | |
| 47 | - | |
| 48 | - auto-connect-retry="${${mongo.autoConnectRetry}}" socket-keep-alive="${${mongo.socketKeepAlive}}" | |
| 49 | - | |
| 50 | - socket-timeout="${${mongo.socketTimeout}}" slave-ok="${${mongo.slaveOk}}" | |
| 51 | - | |
| 52 | - write-number="1" write-timeout="0" write-fsync="true" /> | |
| 53 | - </mongo:mongo>--> | |
| 31 | + <mongo:mongo id="mongo" host="${mongo.db.host}" port="${mongo.db.port}"> | |
| 32 | + <mongo:options connections-per-host="${mongo.connectionsPerHost}" | |
| 33 | + threads-allowed-to-block-for-connection-multiplier="${mongo.threadsAllowedToBlockForConnectionMultiplier}" | |
| 34 | + connect-timeout="${mongo.connectTimeout}" max-wait-time="${mongo.maxWaitTime}" | |
| 35 | + auto-connect-retry="${mongo.autoConnectRetry}" socket-keep-alive="${mongo.socketKeepAlive}" | |
| 36 | + socket-timeout="${mongo.socketTimeout}" write-number="1" | |
| 37 | + write-timeout="0" write-fsync="true"/> | |
| 38 | + </mongo:mongo> | |
| 54 | 39 | </beans> |
platform-resource/resources/config-dev.properties
View file @
5231641
| 1 | 1 | mongo.db.host=localhost |
| 2 | 2 | mongo.db.port=27017 |
| 3 | -mongo.db.dbname=platform | |
| 4 | - | |
| 3 | +mongo.db.dbname=platform1 | |
| 4 | +mongo.db.username=platform | |
| 5 | +mongo.db.password=platform123 | |
| 6 | +mongo.socketTimeout=1000 | |
| 7 | +mongo.connectionsPerHost=20 | |
| 8 | +mongo.threadsAllowedToBlockForConnectionMultiplier=10 | |
| 9 | +mongo.connectTimeout=1000 | |
| 10 | +mongo.maxWaitTime=2000 | |
| 11 | +mongo.autoConnectRetry=true | |
| 12 | +mongo.socketKeepAlive=true | |
| 5 | 13 | |
| 6 | 14 | mysql.db.name=platform |
| 7 | 15 | mysql.db.password=platform123 |
platform-resource/resources/config-test.properties
View file @
5231641
| ... | ... | @@ -2,6 +2,17 @@ |
| 2 | 2 | mongo.db.port=10001 |
| 3 | 3 | mongo.db.dbname=platform |
| 4 | 4 | |
| 5 | +mongo.db.username=platform | |
| 6 | +mongo.db.password=platform123 | |
| 7 | +mongo.socketTimeout=1000 | |
| 8 | +mongo.connectionsPerHost=20 | |
| 9 | +mongo.threadsAllowedToBlockForConnectionMultiplier=10 | |
| 10 | +mongo.connectTimeout=1000 | |
| 11 | +mongo.maxWaitTime=2000 | |
| 12 | +mongo.autoConnectRetry=true | |
| 13 | +mongo.socketKeepAlive=true | |
| 14 | + | |
| 15 | + | |
| 5 | 16 | |
| 6 | 17 | mysql.db.name=platform |
| 7 | 18 | mysql.db.password=platform123 |