1.数据库

![7{{VQ9~961EZ0{[{P$DYBF.png

crm-3_市场活动.sqlcrm-4线索客户联系人交易.sqldictionary.sqltbl_user.sql

数据字典表数据

tbl_dic_type.sqltbl_dic_value.sql

2.创建一个空的工程(IDEA2022.2.1)

image.png

3.创建一个新的meaven项目(IDEA2022.2.1)

3.1设置相关的meaven
meaven修改本地仓库地址
第一步:找到 apache-maven-3.8.6-bin\apache-maven-3.8.6\conf
第二步:打开conf中settings.xml修改如下

  1. <settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
  4. <!-- localRepository
  5. | The path to the local repository maven will use to store artifacts.
  6. |
  7. | Default: ${user.home}/.m2/repository
  8. <localRepository>/path/to/local/repo</localRepository>
  9. -->
  10. <localRepository>修改为你想要改的地址</localRepository>
  11. 例如:
  12. <localRepository>E:/Program/Project/Projectjava/reposity</localRepository>

在IDEA中修改设置
image.png
3.2创建一个新的Module项目
image.png
image.png

4.修改目录

image.png
image.png
image.png

设置编码格式

image.png

5.添加依赖

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  3. <modelVersion>4.0.0</modelVersion>
  4. <groupId>com.bjpowernode</groupId>
  5. <artifactId>crm</artifactId>
  6. <packaging>war</packaging>
  7. <version>1.0-SNAPSHOT</version>
  8. <name>crm Maven Webapp</name>
  9. <url>http://maven.apache.org</url>
  10. <!-- 集中定义依赖版本号 -->
  11. <properties>
  12. <!--单元测试的依赖-->
  13. <junit.version>4.12</junit.version>
  14. <!--spring的相关依赖-->
  15. <spring.version>5.2.5.RELEASE</spring.version>
  16. <!--mybatis的相关依赖-->
  17. <mybatis.version>3.5.1</mybatis.version>
  18. <!--mybaits与spring整合的依赖-->
  19. <mybatis.spring.version>1.3.1</mybatis.spring.version>
  20. <!--mybatis支持的分页插件的依赖-->
  21. <mybatis.paginator.version>1.2.15</mybatis.paginator.version>
  22. <!--mysql的依赖-->
  23. <mysql.version>5.1.32</mysql.version>
  24. <!--slf4j日志依赖-->
  25. <slf4j.version>1.6.4</slf4j.version>
  26. <!--阿里的数据库连接池-->
  27. <druid.version>1.1.12</druid.version>
  28. <!--分页插件的依赖-->
  29. <pagehelper.version>5.1.2</pagehelper.version>
  30. <!--JSTL的依赖(jsp的标准标签库)-->
  31. <jstl.version>1.2</jstl.version>
  32. <!--servlet的依赖-->
  33. <servlet-api.version>3.0.1</servlet-api.version>
  34. <!--jsp的依赖-->
  35. <jsp-api.version>2.0</jsp-api.version>
  36. <!--jackson的依赖,springmvc框架默认进行JSON转换的依赖工具-->
  37. <jackson.version>2.9.6</jackson.version>
  38. </properties>
  39. <dependencies>
  40. <!-- spring -->
  41. <dependency>
  42. <groupId>org.springframework</groupId>
  43. <artifactId>spring-context</artifactId>
  44. <version>${spring.version}</version>
  45. </dependency>
  46. <dependency>
  47. <groupId>org.springframework</groupId>
  48. <artifactId>spring-beans</artifactId>
  49. <version>${spring.version}</version>
  50. </dependency>
  51. <dependency>
  52. <groupId>org.springframework</groupId>
  53. <artifactId>spring-webmvc</artifactId>
  54. <version>${spring.version}</version>
  55. </dependency>
  56. <dependency>
  57. <groupId>org.springframework</groupId>
  58. <artifactId>spring-jdbc</artifactId>
  59. <version>${spring.version}</version>
  60. </dependency>
  61. <dependency>
  62. <groupId>org.springframework</groupId>
  63. <artifactId>spring-aspects</artifactId>
  64. <version>${spring.version}</version>
  65. </dependency>
  66. <dependency>
  67. <groupId>org.springframework</groupId>
  68. <artifactId>spring-jms</artifactId>
  69. <version>${spring.version}</version>
  70. </dependency>
  71. <dependency>
  72. <groupId>org.springframework</groupId>
  73. <artifactId>spring-context-support</artifactId>
  74. <version>${spring.version}</version>
  75. </dependency>
  76. <dependency>
  77. <groupId>org.springframework</groupId>
  78. <artifactId>spring-test</artifactId>
  79. <version>5.2.5.RELEASE</version>
  80. </dependency>
  81. <!-- Mybatis -->
  82. <dependency>
  83. <groupId>org.mybatis</groupId>
  84. <artifactId>mybatis</artifactId>
  85. <version>${mybatis.version}</version>
  86. </dependency>
  87. <dependency>
  88. <groupId>org.mybatis</groupId>
  89. <artifactId>mybatis-spring</artifactId>
  90. <version>${mybatis.spring.version}</version>
  91. </dependency>
  92. <dependency>
  93. <groupId>com.github.miemiedev</groupId>
  94. <artifactId>mybatis-paginator</artifactId>
  95. <version>${mybatis.paginator.version}</version>
  96. </dependency>
  97. <dependency>
  98. <groupId>com.github.pagehelper</groupId>
  99. <artifactId>pagehelper</artifactId>
  100. <version>${pagehelper.version}</version>
  101. </dependency>
  102. <!-- MySql -->
  103. <dependency>
  104. <groupId>mysql</groupId>
  105. <artifactId>mysql-connector-java</artifactId>
  106. <version>${mysql.version}</version>
  107. </dependency>
  108. <!-- 连接池 -->
  109. <dependency>
  110. <groupId>com.alibaba</groupId>
  111. <artifactId>druid</artifactId>
  112. <version>${druid.version}</version>
  113. </dependency>
  114. <!-- junit -->
  115. <dependency>
  116. <groupId>junit</groupId>
  117. <artifactId>junit</artifactId>
  118. <version>${junit.version}</version>
  119. <scope>test</scope>
  120. </dependency>
  121. <!-- JSP相关 -->
  122. <dependency>
  123. <groupId>jstl</groupId>
  124. <artifactId>jstl</artifactId>
  125. <version>${jstl.version}</version>
  126. </dependency>
  127. <dependency>
  128. <groupId>javax.servlet</groupId>
  129. <artifactId>javax.servlet-api</artifactId>
  130. <version>3.0.1</version>
  131. <scope>provided</scope>
  132. </dependency>
  133. <dependency>
  134. <groupId>javax.servlet</groupId>
  135. <artifactId>jsp-api</artifactId>
  136. <scope>provided</scope>
  137. <version>${jsp-api.version}</version>
  138. </dependency>
  139. <!-- Jackson Json处理工具包 -->
  140. <dependency>
  141. <groupId>com.fasterxml.jackson.core</groupId>
  142. <artifactId>jackson-databind</artifactId>
  143. <version>${jackson.version}</version>
  144. </dependency>
  145. <!--poi依赖-->
  146. <dependency>
  147. <groupId>org.apache.poi</groupId>
  148. <artifactId>poi</artifactId>
  149. <version>3.15</version>
  150. </dependency>
  151. <!-- 文件上传 -->
  152. <dependency>
  153. <groupId>commons-fileupload</groupId>
  154. <artifactId>commons-fileupload</artifactId>
  155. <version>1.3.1</version>
  156. </dependency>
  157. <!-- Log4j2依赖的JAR配置 -->
  158. <dependency>
  159. <groupId>org.apache.logging.log4j</groupId>
  160. <artifactId>log4j-api</artifactId>
  161. <version>2.3</version>
  162. </dependency>
  163. <dependency>
  164. <groupId>org.apache.logging.log4j</groupId>
  165. <artifactId>log4j-core</artifactId>
  166. <version>2.3</version>
  167. </dependency>
  168. </dependencies>
  169. <!-- 插件配置 -->
  170. <build>
  171. <finalName>crm</finalName>
  172. <plugins>
  173. <plugin>
  174. <groupId>org.apache.maven.plugins</groupId>
  175. <artifactId>maven-compiler-plugin</artifactId>
  176. <configuration>
  177. <source>1.8</source>
  178. <target>1.8</target>
  179. <encoding>UTF-8</encoding>
  180. </configuration>
  181. </plugin>
  182. </plugins>
  183. <!--识别所有的配置文件-->
  184. <resources>
  185. <resource>
  186. <directory>src/main/java</directory>
  187. <includes>
  188. <include>**/*.properties</include>
  189. <include>**/*.xml</include>
  190. </includes>
  191. <filtering>false</filtering>
  192. </resource>
  193. <resource>
  194. <directory>src/main/resources</directory>
  195. <includes>
  196. <include>**/*.properties</include>
  197. <include>**/*.xml</include>
  198. </includes>
  199. <filtering>false</filtering>
  200. </resource>
  201. </resources>
  202. </build>
  203. </project>

6.添加配置文件

  1. jdbc.driverClassName=com.mysql.jdbc.Driver
  2. jdbc.url=jdbc:mysql://127.0.0.1:3306/crm2008?useUnicode=true&characterEncoding=UTF-8
  3. jdbc.username=root
  4. jdbc.password=123456
  1. <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  2. "http://mybatis.org/dtd/mybatis-3-config.dtd">
  3. <configuration>
  4. <!--设置日志输出语句,显示相应操作的sql语名-->
  5. <settings>
  6. <setting name="logImpl" value="STDOUT_LOGGING"/>
  7. </settings>
  8. </configuration>
  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"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
  6. <!--读取属性文件-->
  7. <context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
  8. <!--配置数据源-->
  9. <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
  10. <property name="driverClassName" value="${jdbc.driverClassName}"></property>
  11. <property name="url" value="${jdbc.url}"></property>
  12. <property name="username" value="${jdbc.username}"></property>
  13. <property name="password" value="${jdbc.password}"></property>
  14. </bean>
  15. <!--配置SqlSessionFactoryBean-->
  16. <bean class="org.mybatis.spring.SqlSessionFactoryBean">
  17. <!--配置数据源-->
  18. <property name="dataSource" ref="dataSource"></property>
  19. <!--配置SqlMapConfig.xml核心配置-->
  20. <property name="configLocation" value="classpath:SqlMapConfig.xml"></property>
  21. <!--注册实体类-->
  22. <property name="typeAliasesPackage" value="com.bjpowernode.crm.model"></property>
  23. </bean>
  24. <!--注册mapper.xml文件-->
  25. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  26. <property name="basePackage" value="com.bjpowernode.crm.mapper"></property>
  27. </bean>
  28. </beans>
  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"
  4. xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
  5. xmlns:aop="http://www.springframework.org/schema/aop"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://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 https://www.springframework.org/schema/aop/spring-aop.xsd">
  7. <!--添加包扫描-->
  8. <context:component-scan base-package="com.bjpowernode.crm.service.impl"></context:component-scan>
  9. <!--添加事务管理器-->
  10. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  11. <!--切记切记:配置数据源-->
  12. <property name="dataSource" ref="dataSource"></property>
  13. </bean>
  14. <!--配置事务切面-->
  15. <tx:advice id="myadvice" transaction-manager="transactionManager">
  16. <tx:attributes>
  17. <tx:method name="*select*" read-only="true"/>
  18. <tx:method name="*find*" read-only="true"/>
  19. <tx:method name="*serach*" read-only="true"/>
  20. <tx:method name="*get*" read-only="true"/>
  21. <tx:method name="*insert*" propagation="REQUIRED"/>
  22. <tx:method name="*add*" propagation="REQUIRED"/>
  23. <tx:method name="*save*" propagation="REQUIRED"/>
  24. <tx:method name="*set*" propagation="REQUIRED"/>
  25. <tx:method name="*update*" propagation="REQUIRED"/>
  26. <tx:method name="*change*" propagation="REQUIRED"/>
  27. <tx:method name="*modify*" propagation="REQUIRED"/>
  28. <tx:method name="*delete*" propagation="REQUIRED"/>
  29. <tx:method name="*drop*" propagation="REQUIRED"/>
  30. <tx:method name="*remove*" propagation="REQUIRED"/>
  31. <tx:method name="*clear*" propagation="REQUIRED"/>
  32. <tx:method name="*" propagation="SUPPORTS"/>
  33. </tx:attributes>
  34. </tx:advice>
  35. <!--配置切入点+绑定-->
  36. <aop:config>
  37. <aop:pointcut id="mycut" expression="execution(* com.bjpowernode.crm..service.*.*(..))"></aop:pointcut>
  38. <aop:advisor advice-ref="myadvice" pointcut-ref="mycut"></aop:advisor>
  39. </aop:config>
  40. </beans>
  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"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:mvc="http://www.springframework.org/schema/mvc"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
  7. <!--添加包扫描-->
  8. <context:component-scan base-package="com.bjpowernode.crm.controller"></context:component-scan>
  9. <!--添加注解驱动-->
  10. <mvc:annotation-driven></mvc:annotation-driven>
  11. <!-- 配置视图解析器 -->
  12. <bean id="viewResolver"
  13. class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  14. <property name="prefix" value="/WEB-INF/pages/"/>
  15. <property name="suffix" value=".jsp"/>
  16. </bean>
  17. <!-- 配置文件上传解析器 id:必须是multipartResolver-->
  18. <!--<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
  19. <property name="maxUploadSize" value="#{1024*1024*80}"/>
  20. <property name="defaultEncoding" value="utf-8"/>
  21. </bean>-->
  22. </beans>

修改web.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app xmlns="http://java.sun.com/xml/ns/javaee"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
  5. http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  6. version="3.0">
  7. <!--添加中文编码过滤器
  8. private String encoding;
  9. private boolean forceRequestEncoding;
  10. private boolean forceResponseEncoding;
  11. -->
  12. <filter>
  13. <filter-name>encode</filter-name>
  14. <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
  15. <init-param>
  16. <param-name>encoding</param-name>
  17. <param-value>UTF-8</param-value>
  18. </init-param>
  19. <init-param>
  20. <param-name>forceRequestEncoding</param-name>
  21. <param-value>true</param-value>
  22. </init-param>
  23. <init-param>
  24. <param-name>forceResponseEncoding</param-name>
  25. <param-value>true</param-value>
  26. </init-param>
  27. </filter>
  28. <filter-mapping>
  29. <filter-name>encode</filter-name>
  30. <url-pattern>/*</url-pattern>
  31. </filter-mapping>
  32. <!--注册SpringMVC框架-->
  33. <servlet>
  34. <servlet-name>springmvc</servlet-name>
  35. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  36. <init-param>
  37. <param-name>contextConfigLocation</param-name>
  38. <param-value>classpath:springmvc.xml</param-value>
  39. </init-param>
  40. <load-on-startup>1</load-on-startup>
  41. </servlet>
  42. <servlet-mapping>
  43. <servlet-name>springmvc</servlet-name>
  44. <url-pattern>/</url-pattern>
  45. </servlet-mapping>
  46. <servlet-mapping>
  47. <servlet-name>springmvc</servlet-name>
  48. <url-pattern>*.do</url-pattern>
  49. </servlet-mapping>
  50. <!--注册Spring框架,目的就是启动spring容器-->
  51. <listener>
  52. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  53. </listener>
  54. <context-param>
  55. <param-name>contextConfigLocation</param-name>
  56. <param-value>classpath:applicationContext_*.xml</param-value>
  57. </context-param>
  58. <!-- 欢迎页,默认进入index controller -->
  59. <welcome-file-list>
  60. <welcome-file>/</welcome-file>
  61. </welcome-file-list>
  62. </web-app>

7.修改前端页面

image.png

8.部署到Tomcat服务器上

image.png