spring+struts2+maven+mongodb

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>mongodb-demo</groupId>
	<artifactId>mongodb-demo</artifactId>
	<packaging>war</packaging>
	<version>0.0.1-SNAPSHOT</version>
	<name>mongodb-demo</name>
	<properties>
		<project.build.finalName>mongodb-demo</project.build.finalName>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<org.apache.struts.version>2.3.15.1</org.apache.struts.version>
		<org.springframework.version>3.2.8.RELEASE</org.springframework.version>
		<deploy.home>${env.TOMCAT_HOME}/webapps/${project.build.finalName}</deploy.home>
	</properties>
	<dependencyManagement>
		<dependencies>
			<!-- Struts Framework Configuration -->
			<dependency>
				<groupId>org.apache.struts</groupId>
				<artifactId>struts2-core</artifactId>
				<version>${org.apache.struts.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.struts</groupId>
				<artifactId>struts2-convention-plugin</artifactId>
				<version>${org.apache.struts.version}</version>
			</dependency>
			<dependency>
				<groupId>org.apache.struts</groupId>
				<artifactId>struts2-spring-plugin</artifactId>
				<version>${org.apache.struts.version}</version>
				<exclusions>
					<exclusion>
						<groupId>org.springframework</groupId>
						<artifactId>spring-beans</artifactId>
					</exclusion>
					<exclusion>
						<groupId>org.springframework</groupId>
						<artifactId>spring-core</artifactId>
					</exclusion>
					<exclusion>
						<groupId>org.springframework</groupId>
						<artifactId>spring-context</artifactId>
					</exclusion>
					<exclusion>
						<groupId>org.springframework</groupId>
						<artifactId>spring-web</artifactId>
					</exclusion>
				</exclusions>
			</dependency>
			<dependency>
				<groupId>org.apache.struts</groupId>
				<artifactId>struts2-jasperreports-plugin</artifactId>
				<version>${org.apache.struts.version}</version>
			</dependency>
			<!-- Spring Framework Configuration -->
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-context</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-beans</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-core</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-tx</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-expression</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework</groupId>
				<artifactId>spring-web</artifactId>
				<version>${org.springframework.version}</version>
			</dependency>
			<dependency>
				<groupId>org.springframework.data</groupId>
				<artifactId>spring-data-commons</artifactId>
				<version>1.7.1.RELEASE</version>
			</dependency>
			<!-- MongoDB -->
			<dependency>
				<groupId>org.springframework.data</groupId>
				<artifactId>spring-data-mongodb</artifactId>
				<version>1.4.2.RELEASE</version>
			</dependency>
			<dependency>
				<groupId>org.mongodb</groupId>
				<artifactId>mongo-java-driver</artifactId>
				<version>2.11.4</version>
			</dependency>
		</dependencies>
	</dependencyManagement>
	<dependencies>
		<!-- Struts Framework Configuration -->
		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-convention-plugin</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-spring-plugin</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-jasperreports-plugin</artifactId>
		</dependency>
		<!-- Spring Framework Configuration -->
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-expression</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-commons</artifactId>
		</dependency>
		<!-- MongoDB -->
		<dependency>
			<groupId>org.springframework.data</groupId>
			<artifactId>spring-data-mongodb</artifactId>
		</dependency>
		<dependency>
			<groupId>org.mongodb</groupId>
			<artifactId>mongo-java-driver</artifactId>
		</dependency>

		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
			<version>3.7-beta2</version>
		</dependency>
		<!-- db and db driver -->
		<!-- Report Tools -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>1.6.3</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<version>1.6.3</version>
		</dependency>
		<dependency>
			<groupId>org.apache.ant</groupId>
			<artifactId>ant</artifactId>
			<version>1.8.4</version>
		</dependency>
		<dependency>
			<groupId>commons-codec</groupId>
			<artifactId>commons-codec</artifactId>
			<version>1.6</version>
		</dependency>
		<!-- json 插件 -->
		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-json-plugin</artifactId>
			<version>2.2.3</version>
		</dependency>
		<dependency>
			<groupId>org.codehaus.groovy</groupId>
			<artifactId>groovy</artifactId>
			<version>1.8.3</version>
		</dependency>
		<dependency>
			<groupId>com.lowagie</groupId>
			<artifactId>itextasian</artifactId>
			<version>1.0</version>
		</dependency>
		<dependency>
			<groupId>commons-digester</groupId>
			<artifactId>commons-digester</artifactId>
			<version>1.7</version>
		</dependency>
		<dependency>
			<groupId>itext</groupId>
			<artifactId>itext</artifactId>
			<version>2.1.7</version>
		</dependency>
		<dependency>
			<groupId>com</groupId>
			<artifactId>csvjdbc</artifactId>
			<version>1.0</version>
		</dependency>
		<dependency>
			<groupId>org.apache.tika</groupId>
			<artifactId>tika-core</artifactId>
			<version>1.0</version>
		</dependency>
		<!-- <dependency> <groupId>jofc2</groupId> <artifactId>jofc2</artifactId> 
			<version>2.2</version> </dependency> -->
		<dependency>
			<groupId>com.thoughtworks.xstream</groupId>
			<artifactId>xstream</artifactId>
			<version>1.3.1</version>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>servlet-api</artifactId>
			<version>2.5</version>
			<type>jar</type>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.servlet.jsp</groupId>
			<artifactId>jsp-api</artifactId>
			<version>2.1</version>
			<type>jar</type>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.shiro</groupId>
			<artifactId>shiro-all</artifactId>
			<version>1.2.1</version>
		</dependency>

		<dependency>
			<groupId>javax.annotation</groupId>
			<artifactId>jsr250-api</artifactId>
			<version>1.0</version>
		</dependency>

		<dependency>
			<groupId>net.sf.json-lib</groupId>
			<artifactId>json-lib</artifactId>
			<version>2.3</version>
			<classifier>jdk15</classifier>
		</dependency>

		<dependency>
			<groupId>com.alibaba</groupId>
			<artifactId>fastjson</artifactId>
			<version>1.1.26</version>
		</dependency>

		<dependency>
			<groupId>javax.jms</groupId>
			<artifactId>jms</artifactId>
			<version>1.1</version>
		</dependency>

		<dependency>
			<groupId>org.apache.activemq</groupId>
			<artifactId>activemq-all</artifactId>
			<version>5.7.0</version>
		</dependency>

		<dependency>
			<!-- jsoup HTML parser library @ http://jsoup.org/ -->
			<groupId>org.jsoup</groupId>
			<artifactId>jsoup</artifactId>
			<version>1.7.3</version>
		</dependency>

		<!-- ACCA Java Application Framework -->
		<!-- <dependency> -->
		<!-- <groupId>cn.com.acca</groupId> -->
		<!-- <artifactId>ajaf</artifactId> -->
		<!-- </dependency> -->

	</dependencies>
	<build>
		<finalName>${project.build.finalName}</finalName>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<filtering>true</filtering>
			</resource>
			<resource>
				<directory>src/main/webapp</directory>
				<filtering>false</filtering>
				<excludes>
					<exclude>**</exclude>
				</excludes>
			</resource>
		</resources>
		<testResources>
			<testResource>
				<directory>src/test/resources</directory>
				<filtering>true</filtering>
			</testResource>
		</testResources>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-clean-plugin</artifactId>
					<version>2.5</version>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-compiler-plugin</artifactId>
					<version>2.5.1</version>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-resources-plugin</artifactId>
					<version>2.6</version>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-surefire-plugin</artifactId>
					<version>2.12.4</version>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-war-plugin</artifactId>
					<version>2.3</version>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-antrun-plugin</artifactId>
					<version>1.7</version>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-site-plugin</artifactId>
					<version>3.1</version>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-project-info-reports-plugin</artifactId>
					<version>2.5.1</version>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-checkstyle-plugin</artifactId>
					<version>2.9.1</version>
				</plugin>
			</plugins>
		</pluginManagement>
		<plugins>
			<plugin>
				<artifactId>maven-clean-plugin</artifactId>
			</plugin>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
			</plugin>
			<plugin>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<argLine>-Xmx=512m -XX:MaxPermSize=256m</argLine>
					<forkMode>once</forkMode>
					<argLine>-enableassertions</argLine>
					<testFailureIgnore>true</testFailureIgnore>
					<parallel>methods</parallel>
					<threadCount>1</threadCount>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-war-plugin</artifactId>
				<configuration>
					<warSourceDirectory>${project.basedir}/src/main/webapp
					</warSourceDirectory>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-site-plugin</artifactId>
			</plugin>
			<plugin>
				<artifactId>maven-checkstyle-plugin</artifactId>
				<configuration>
					<configLocation>coding_standards_checkstyle.xml</configLocation>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<reporting>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-project-info-reports-plugin</artifactId>
				<version>2.5.1</version>
				<reportSets>
					<reportSet>
						<reports>
							<report>index</report>
							<report>dependency-management</report>
							<report>dependencies</report>
							<report>plugin-management</report>
							<report>plugins</report>
							<report>summary</report>
						</reports>
						<configuration>
							<dependencyDetailsEnabled>false</dependencyDetailsEnabled>
							<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
						</configuration>
					</reportSet>
				</reportSets>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jxr-plugin</artifactId>
				<version>2.3</version>
				<configuration>
					<aggregate>true</aggregate>
				</configuration>
				<reportSets>
					<reportSet>
						<id>default</id>
						<reports>
							<report>jxr</report>
						</reports>
					</reportSet>
				</reportSets>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-checkstyle-plugin</artifactId>
				<version>2.9.1</version>
				<configuration>
					<configLocation>coding_standards_checkstyle.xml</configLocation>
				</configuration>
				<reportSets>
					<reportSet>
						<reports>
							<report>checkstyle</report>
						</reports>
					</reportSet>
				</reportSets>
			</plugin>
		</plugins>
	</reporting>
	<profiles>
		<profile>
			<id>dev</id>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<executions>
							<execution>
								<id>hot-deploy</id>
								<phase>process-resources</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<target>
					<copy todir="${deploy.home}" failonerror="false">
					<fileset dir="${project.basedir}/src/main/webapp" />
										</copy>
			<copy todir="${deploy.home}/WEB-INF/classes" failonerror="false">
			<fileset dir="${project.basedir}/target/classes" />
										</copy>
									</target>
								</configuration>
							</execution>
							<execution>
								<id>dev-deploy</id>
								<phase>install</phase>
								<goals>
									<goal>run</goal>
								</goals>
								<configuration>
									<target>
							<delete dir="${deploy.home}" />
							<mkdir dir="${deploy.home}" />
					<copy todir="${deploy.home}" failonerror="false">
								<fileset
			      dir="${project.basedir}/target/${project.build.finalName}" />
										</copy>
									</target>
								</configuration>
							</execution>

						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>

 

mongo.host=127.0.0.1
mongo.port=27017
mongo.connectionsPerHost=8
mongo.connectTimeout=1000
mongo.maxWaitTime=1500
mongo.autoConnectRetry=true
mongo.socketTimeout=2000
mongo.threadsAllowedToBlockForConnectionMultiplier=4
mongo.socketKeepAlive=true
mongo.fsync=true
mongo.slaveOk=true

 

<?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:mongo="http://www.springframework.org/schema/data/mongo"
	xsi:schemaLocation="http://www.springframework.org/schema/context  
          http://www.springframework.org/schema/context/spring-context-3.0.xsd  
          http://www.springframework.org/schema/data/mongo  
          http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd  
          http://www.springframework.org/schema/beans  
          http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

	<context:annotation-config />
	<context:component-scan base-package="com.mongo.*" />
	<context:property-placeholder location="classpath:/mongo.properties" />

	<mongo:mongo host="${mongo.host}" port="${mongo.port}">
		<mongo:options connections-per-host="${mongo.connectionsPerHost}"
			threads-allowed-to-block-for-connection-multiplier="${mongo.threadsAllowedToBlockForConnectionMultiplier}"
			connect-timeout="${mongo.connectTimeout}" max-wait-time="${mongo.maxWaitTime}"
			auto-connect-retry="${mongo.autoConnectRetry}" socket-keep-alive="${mongo.socketKeepAlive}"
			socket-timeout="${mongo.socketTimeout}" slave-ok="${mongo.slaveOk}"
			write-number="1" write-timeout="0" write-fsync="true" />
	</mongo:mongo>

	<!-- mongo的工厂,通过它来取得mongo实例,dbname为mongodb的数据库名,没有的话会自动创建 -->
	<mongo:db-factory dbname="test01" mongo-ref="mongo" />

	<!-- mongodb的主要操作对象,所有对mongodb的增删改查的操作都是通过它完成 -->
	<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
		<constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
	</bean>


	<!-- 映射转换器,扫描back-package目录下的文件,根据注释,把它们作为mongodb的一个collection的映射 -->
	<mongo:mapping-converter base-package="com.mongo.entity.*.entity" />
	<!-- mongodb bean的仓库目录,会自动扫描扩展了MongoRepository接口的接口进行注入 -->
	<mongo:repositories base-package="com.mongo.dao.*.dao" />


</beans>

 

时间有限,刚刚把项目框架打起来,后续会继续做页面的相关实现

 

你可能感兴趣的:(mongodb)