把我的第一篇奉献给毕设!!!
一、项目介绍
基于SSM框架实现企业人事管理系统
一、主要功能:实现部门信息、
员工信息、
员工工资、
出勤记录、
奖罚记录、
考核记录的 增删改查功能。
二、部分图片显示
二、应用技术
1、基础框架- ssm(SpringMVC+Spring+MyBatis)
2、数据库- SQLserver2008
3、前端- jsp,bootstrap,jquery,css,js,Ajax前端校验
5、分页- pagehelper
6、逆向工程- MyBatis Generator
三、开发步骤
一、准备运行环境:
eclipse;
tomcat8.5
jdk1.7
以下为个人观点,如有否定,是你的对~~~不杠~~~轻喷,中肯建议,必采纳~~~
二、搭建框架
1、打开eclipse,搭建框架。(
2>不会在com中建空包的宝宝看这里https://blog.csdn.net/renjingzhaozhao/article/details/105490929
我个人对分层结构要求严谨,唉看到过一些项目分层,望过去,??? 这tm是啥?,,真的脑壳疼。。。
扩展以下分层结构,摘自《spring+mybatis企业应用实战》
三、导入jar包
文章结尾,我会留下项目压缩包,里面有jar包。
四、写配置文件
我也是从网上抄来的,大家的也都差不多,添加一点自己项目的东西就行。
配置文件主要放在了config包中,其他位置,我不放会报错,原因我也不知道哦~~~学艺不精。。。等我懂了再来解决~~~
<1、配置applicationContext文件。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
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:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
<!-- Spring 配置文件 dao -->
<!-- 加载配置文件 -->
<context:property-placeholder location="classpath:dbconfig.properties" />
<!-- 数据库连接池 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<!-- 在db.properties中取值,${db.properties中的参数名} -->
<property name="driverClass" value="${jdbc.driver}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- mapper配置 -->
<!-- 让spring管理sqlsessionfactory 使用mybatis和spring整合包中的 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 数据库连接池 -->
<property name="dataSource" ref="dataSource" />
<!-- 加载mybatis的全局配置文件 -->
<property name="configLocation" value="classpath:SqlMapConfig.xml" />
</bean>
<!-- 配置Mapper扫描器 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.mapper"/>
</bean>
<!-- 事务控制配置文件 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- 数据源 -->
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 配置事务增强,事务如何切入 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!-- 传播行为 -->
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="create*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="find*" propagation="SUPPORTS" read-only="true" />
<tx:method name="select*" propagation="SUPPORTS" read-only="true" />
<tx:method name="get*" propagation="SUPPORTS" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 切面 -->
<aop:config>
<aop:advisor advice-ref="txAdvice"
pointcut="execution(* com.service.*.*(..))" />
</aop:config>
<!-- @Service扫描 -->
<context:component-scan base-package="com.service"></context:component-scan>
</beans>
<2、配置dbconfig.properties文件。
如果使用其他数据库,需要更改这里。我用的SQLserver
jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.url=jdbc:sqlserver://localhost;DatabaseName=ERP
jdbc.username=sa
jdbc.password=123456
<3、配置log4j.properties文件。
# Global logging configuration
log4j.rootLogger=DEBUG,stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
<4、springmvc.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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
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-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<!-- 扫描controller -->
<context:component-scan base-package="com.controller" />
<!-- Spring 来扫描指定包下的类,并注册被@Component,@Controller,@Service,@Repository等注解标记的组件 -->
<mvc:annotation-driven />
<!-- 对静态资源放行-->
<mvc:resources location="/css/" mapping="/css/**"/>
<mvc:resources location="/js/" mapping="/js/**"/>
<mvc:resources location="/images/" mapping="/images/**"/>
<!-- 配置SpringMVC的视图解析器-->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 前缀 -->
<property name="prefix" value="/WEB-INF/views/" />
<!-- 后缀 -->
<property name="suffix" value=".jsp" />
</bean>
<!-- 两个标准配置 -->
<!-- 将springmvc不能处理的请求交给tomcat -->
<mvc:default-servlet-handler/>
<!-- 能支持springmvc更高级的一些功能 -->
<mvc:annotation-driven/>
</beans>
<5、SqlMapConfig.xml文件
<?xml version="1.0" en