下面交代一下使用的框架
前端: EasyUI+Jquery+Ajax
后台: Spring+Structs2+mybatis
数据库: Oracle
使用工具: MyEclipse12+Maven
操作系统: win7
1.spring.xml
<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd"> <context:component-scan base-package="com.yc.crm"/> <context:property-placeholder location="classpath:jdbc.properties"/> <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"> <property name="driverClassName" value="${jdbc.driver}"/> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> <property name="initialSize" value="${jdbc.initialSize}"/> <property name="maxTotal" value="20"/> </bean> <!-- spring容器 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <!-- 加载mybatis --> <!-- <property name="configLocation" value="classpath:mybatis.xml"/> --> <property name="dataSource" ref="dataSource"/> <property name="typeAliasesPackage" value="com.yc.crm.entity"/> <!--指定类的别名 --> <property name="mapperLocations" value="classpath:com/yc/crm/entity/*.xml"/> <!-- 指定扫描所有指定路径的所有映射文件 --> </bean> <!-- 加载所有映射接口bean bean的id为接口名的首字母小写 为UserMapper 和 MsgMapper这些类注入参数 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.yc.crm.mapper"/> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> </bean> <!-- 事务管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <!-- Mybatis整合事务 声明式事务处理 还有一种是通知式--> <tx:annotation-driven transaction-manager="transactionManager"/> </beans>
2.structs.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devMode" value="false" /> <!-- 把action交个spring容器管理,生成action Bean --> <constant name="struts.objectFactory" value="spring" /> <package name="default" namespace="/" extends="json-default"> <interceptors> <interceptor name="loginInterceptor" class="com.yc.crm.web.interceptor.LoginInterceptor"></interceptor> <interceptor name="characterInterceptor" class="com.yc.crm.web.interceptor.CharacterInterceptor"></interceptor> <interceptor-stack name="myStack"> <interceptor-ref name="loginInterceptor" /> <interceptor-ref name="characterInterceptor" /> <interceptor-ref name="defaultStack" /> </interceptor-stack> </interceptors> <default-interceptor-ref name="myStack"/> <!-- 设置默认拦截器 --> <action name="*_*" class="com.yc.crm.web.action.{1}Action" method="{2}"> <result>/${result}.jsp</result> <result name="login_success" type="redirect">/${result}.jsp</result> <result name="fail">/fail.jsp</result> <result name="json" type="json"> <!-- 如果action中返回的是一个json结果,那么数据类型也是json,并且以rows为根发送给客户端 --> <param name="root">jsondata</param> </result> </action> </package> </struts>
3.pom.xml
<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>com.yc.crm</groupId> <artifactId>crm</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>crm</name> <url>http://maven.apache.org</url> <dependencies> <!-- 日志包 --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.2.8</version> </dependency> <!-- spring和mybatis的整合包 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.2</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>4.1.6.RELEASE</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-dbcp2</artifactId> <version>2.1</version> </dependency> <dependency> <groupId>com.oracle</groupId> <artifactId>oracle-driver</artifactId> <version>11g</version> </dependency> <!-- spring和structs的整合包 --> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>2.3.24</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-spring-plugin</artifactId> <version>2.3.24</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>3.0-alpha-1</version> <!-- <scope>provided</scope> --> </dependency> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-dojo-plugin</artifactId> <version>2.3.24</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-json-plugin</artifactId> <version>2.3.24</version> </dependency> <!-- <dependency> <groupId>org.jboss.spec.javax.servlet.jstl</groupId> <artifactId>jboss-jstl-api_1.2_spec</artifactId> <version>1.1.2.Final</version> <scope>provided</scope> </dependency> --> </dependencies> <build> <finalName>crm</finalName> </build> </project>
4.jdbc.properties
jdbc.driver=oracle.jdbc.OracleDriver jdbc.url=jdbc:oracle:thin:@localhost:1521:orcl jdbc.username=scott jdbc.password=a jdbc.initialSize=5
其中还有许多东西没有弄清楚,在后面的总结会一一解决。
1.maven
2.spring的缓存和事务
3.jetty
我是菜鸟,我在路上。
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2025-01-02 01:30:54