当我尝试配置spring mongoDB xml(config)文件时,你可以说为什么这里出错了。 (以下描述中的错误)
答案 0 :(得分:0)
此配置基于我的项目。您可以根据
修改它 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd"
default-autowire="byName">
<context:annotation-config />
<context:component-scan base-package="com.soe.mongo" />
<context:property-placeholder location="classpath:soe-mongodao.properties" />
<bean id="mongoCredentials" class="org.springframework.data.authentication.UserCredentials">
<constructor-arg name="username" value="#{mongoURI.username}" />
<constructor-arg name="password" value="#{new java.lang.String(mongoURI.password)}" />
</bean>
<bean class="com.mongodb.MongoURI" id="mongoURI">
<constructor-arg value="${soe.db.spring.data.mongo.url}" />
</bean>
<bean class="com.mongodb.Mongo" id="mongo">
<constructor-arg ref="mongoURI" />
</bean>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongo" ref="mongo" />
<constructor-arg name="databaseName" value="${soe.db.spring.data.mongodb.database}" />
<constructor-arg name="userCredentials" ref="mongoCredentials"/>
</bean>
<!-- Use this post processor to translate any MongoExceptions thrown in
@Repository annotated classes -->
<bean
class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
答案 1 :(得分:0)
在上下文xml中添加这些并将其添加到类路径中。在属性文件中添加相应的属性。
#!/bin/bash
old_packets=0
while true; do
packets=$(awk '$1 == "eth0:"{print $3}' /proc/net/dev)
if ((old_packets)); then
clear
echo "$(bc <<< "($packets - $old_packets) / 10") packets/seconds"
fi
old_packets=$packets
sleep 10
done