目录:
(1)CRM技术架构
(2)CRM软件开发生命周期
(3)CRM 物理结构设计
(4)搭建开发环境
(1)CRM技术架构


(2)CRM软件开发生命周期





(3)CRM 物理结构设计







(4)搭建开发环境

首先创建一个空的项目:


创建工程:Module:
选择Maven骨架:



补全目录:创建目录:

添加依赖:pom.xml:
- "1.0" encoding="UTF-8"?>
-
"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/xsd/maven-4.0.0.xsd">
-
4.0.0 -
-
com.bjpowernode.crm -
crm -
1.0-SNAPSHOT -
war -
-
crm Maven Webapp -
-
http://www.example.com -
-
UTF-8 -
1.7 -
1.7 -
-
-
-
junit -
junit -
4.11 -
test -
-
-
-
mysql -
mysql-connector-java -
5.1.43 -
-
-
-
com.alibaba -
druid -
1.1.1 -
-
-
-
org.mybatis -
mybatis -
3.4.1 -
-
-
-
org.springframework -
spring-context -
4.3.9.RELEASE -
-
-
org.springframework -
spring-aop -
4.3.9.RELEASE -
-
-
org.springframework -
spring-core -
4.3.9.RELEASE -
-
-
org.springframework -
spring-beans -
4.3.9.RELEASE -
-
-
org.springframework -
spring-jdbc -
4.3.9.RELEASE -
-
-
org.springframework -
spring-tx -
4.3.9.RELEASE -
-
-
org.springframework -
spring-web -
4.3.9.RELEASE -
-
-
org.springframework -
spring-webmvc -
4.3.9.RELEASE -
-
-
org.springframework -
spring-oxm -
4.3.9.RELEASE -
-
-
-
org.aspectj -
aspectjweaver -
1.8.9 -
-
-
-
org.mybatis -
mybatis-spring -
1.3.0 -
-
-
-
javax.servlet -
javax.servlet-api -
3.1.0 -
-
-
javax.servlet.jsp.jstl -
jstl-api -
1.2 -
-
-
org.apache.taglibs -
taglibs-standard-spec -
1.2.1 -
-
-
org.apache.taglibs -
taglibs-standard-impl -
1.2.1 -
-
-
-
com.fasterxml.jackson.core -
jackson-core -
2.7.3 -
-
-
com.fasterxml.jackson.core -
jackson-databind -
2.7.3 -
-
-
com.fasterxml.jackson.core -
jackson-annotations -
2.7.3 -
-
-
-
org.apache.poi -
poi -
3.15 -
-
-
-
commons-fileupload -
commons-fileupload -
1.3.1 -
-
-
-
org.apache.logging.log4j -
log4j-api -
2.3 -
-
-
org.apache.logging.log4j -
log4j-core -
2.3 -
-
-
org.apache.logging.log4j -
log4j-jcl -
2.3 -
-
-
-
crm -
-
-
-
maven-clean-plugin -
3.1.0 -
-
-
-
maven-resources-plugin -
3.0.2 -
-
-
maven-compiler-plugin -
3.8.0 -
-
-
maven-surefire-plugin -
2.22.1 -
-
-
maven-war-plugin -
3.2.2 -
-
-
maven-install-plugin -
2.5.2 -
-
-
maven-deploy-plugin -
2.8.2 -
-
-
-
设置项目编码:

添加配置文件:
在resources目录下创建
创建Mybatis的配置文件:
mybatis-config.xml:
- "1.0" encoding="UTF-8" ?>
- PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-config.dtd">
-
-
"logImpl" value="STDOUT_LOGGING"/> -
-
- <package name="com.bjpowernode.crm.model"/>
-
-
- <package name="com.bjpowernode.crm.mapper"/>
-
配置数据连接和事务,创建配置文件:applicationContext-datasource.xml
- "1.0" encoding="UTF-8"?>
"http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
-
-
"dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> -
"driverClassName" value="com.mysql.jdbc.Driver"/> -
"username" value="root"/> -
"password" value="123456"/> -
"url" value="jdbc:mysql://192.168.223.133:3306/crm_db?useSSL=false&useUnicode=true&characterEncoding=UTF-8"/> -
-
-
"sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> -
-
"dataSource" ref="dataSource"/> -
-
"configLocation" value="classpath:mybatis-config.xml"/> -
-
-
"mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer"> -
"basePackage" value="com.bjpowernode.crm.mapper"/> -
"sqlSessionFactoryBeanName" value="sqlSessionFactory"/> -
-
-
-
"transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> -
"dataSource" ref="dataSource"/> -
-
-
-
"execution(* com.bjpowernode.crm..service.*.*(..))" id="allMethodPointcut"/> -
"txAdvice" pointcut-ref="allMethodPointcut"/> -
-
"txAdvice" transaction-manager="transactionManager"> -
-
"add*" propagation="REQUIRED" rollback-for="Exception"/> -
"save*" propagation="REQUIRED" rollback-for="Exception"/> -
"edit*" propagation="REQUIRED" rollback-for="Exception"/> -
"update*" propagation="REQUIRED" rollback-for="Exception"/> -
"delete*" propagation="REQUIRED" rollback-for="Exception"/> -
"do*" propagation="REQUIRED" rollback-for="Exception"/> -
"*" propagation="REQUIRED" read-only="true"/> -
-
springmvc 配置:
applicationContext-mvc.xml
- "1.0" encoding="UTF-8"?>
"http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:util="http://www.springframework.org/schema/util"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
default-servlet-handler /> package="com.bjpowernode.crm.web.controller"/> "viewResolver" - class="org.springframework.web.servlet.view.InternalResourceViewResolver">
"prefix" value="/WEB-INF/pages/"/> "suffix" value=".jsp"/>
spring 总配置文件:applicationContext.xml
- "1.0" encoding="UTF-8"?>
"http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:task="http://www.springframework.org/schema/task"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd">
-
-
-
package="com.bjpowernode.crm.service" /> -
- <import resource="applicationContext-datasource.xml" />
web.xml的核心配置文件:
- "1.0" encoding="UTF-8"?>
"http://www.w3.org/2001/XMLSchema-instance" - xmlns="http://java.sun.com/xml/ns/javaee"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- id="dataservice" version="3.0">
-
dataservice application -
-
-
contextConfigLocation -
classpath:applicationContext.xml -
-
-
org.springframework.web.context.ContextLoaderListener -
-
-
-
encodingFilter -
org.springframework.web.filter.CharacterEncodingFilter -
-
encoding -
UTF-8 -
-
-
-
encodingFilter -
/* -
-
-
-
dispatcher -
org.springframework.web.servlet.DispatcherServlet -
-
contextConfigLocation -
classpath:applicationContext-mvc.xml -
-
1 -
-
-
dispatcher -
/ -
-
-
dispatcher -
*.do -
-
-
-
/ -
web.xml中加载 appllicationContext.xml、applicationContext-mvc.xml
当appllicationContext.xml加载的时候加载applicationContext-datasource.xml,当applicationContext-datasource.xml加载的时候加载mybatis-config.xml。这样当服务器启动后,加载web.xml,就把所有的配置文件都加载进来了,
设置maven对配置文件的编译选项
让Maven为我们编译配置文件,Maven默认只会编译java源文件,配置文件不会编译,需要设置
在pom.xml中添加:

添加静态页面:
我们的项目部署到tomcat上的webapps目录下,我们部署的的时候,IDEA和Maven会把webapp目录下所有东西都考到webapps目录下这个项目的名字下面


为了安全,把页面放到WEB-INF目录下面,这样外界就不能直接访问了 ,但是正常的访问页面怎么访问呢?提供Controller,进行验证访问,通过controller访问,css和images不用放到WEB-INF目录下,不需要保护

部署项目到tomcat服务器:



运行:web.xml配置了默认访问controller 中的/,因为没有配置报404