基于IDEA+Maven+SSM员工部门(增删改查)

第一步:部署项目的基本配置
项目的基本文件框架

1、首先项目的基本部署:首先导入需要使用的jar包,由于本项目时Maven工程,所以只需要在pom.xml文件下面,添加jar包的依赖关系就可以了。

org.springframework

spring-webmvc

5.0.6.RELEASE

org.springframework

spring-jdbc

5.0.6.RELEASE

org.springframework

spring-aspects

5.0.6.RELEASE

org.mybatis

mybatis

3.4.6

org.mybatis

mybatis-spring

1.3.2

com.mchange

c3p0

0.9.5.2

com.microsoft.sqlserver

sqljdbc4

4.0

javax.servlet

jstl

1.2

javax.servlet

javax.servlet-api

4.0.0

provided

junit

junit

4.12

org.mybatis.generator

mybatis-generator-core

1.3.6

org.springframework

spring-test

5.0.6.RELEASE

com.github.pagehelper

pagehelper

5.1.4

com.fasterxml.jackson.core

jackson-databind

2.9.5

org.hibernate

hibernate-validator

5.4.1.Final

2、将资源文件在pom.xml文件中,进行文件资源访问的权限,如果不配置该操作,则在读取文件时,项目会报错,找不到该文件。

src/main/webapp

**/*.xml

**/*.properties

**/*.js

**/*.css

true

3、配置web.xml文件信息:启动Spring容器,启动SpringMVC的前端控制器,拦截所有的请求,字码的编码格式,配置服务器发送的请求。

Archetype Created Web Application

contextConfigLocation

classpath:/WEB-INF/applicationContext.xml

org.springframework.web.context.ContextLoaderListener

springmvc

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

/WEB-INF/springmvc-config.xml

springmvc

/

CharacterEncodingFilter

org.springframework.web.filter.CharacterEncodingFilter

encoding

utf-8

forceRequestEncoding

true

forceResponseEncoding

true

CharacterEncodingFilter

/*

HiddenHttpMethodFilter

org.springframework.web.filter.HiddenHttpMethodFilter

HiddenHttpMethodFilter

/*

HttpPutFormContentFilter

org.springframework.web.filter.HttpPutFormContentFilter

HttpPutFormContentFilter

/*

4、配置springmvc-config.xml 文件信息:

Spring 和 SpringMVC 都是容器,但是不同点在于Spring是父容器,SpringMVC是子容器,在SpringMVC中可以知道Spring文件的配置信息,但是反过来,Spring是不知道SpringMVC的配置信息的。所以在进行项目的配置时,Spring 和 SpringMVC 都是分工合作的,SpringMVC只扫描控制器@Controller,主要是包含了网站的跳转逻辑的控制和配置。Spring则需要扫描除了控制器之@Controller外的所有组件.在扫描组件时,use-default-filters=“false” 默认为true,如果是true,则会扫描所有的组件,false则会扫描你自定义的需要扫描的组件。

<?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: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.xsdhttp://www.springframework.org/schema/mvchttp://www.springframework.org/schema/mvc/spring-mvc.xsd";>

context:component-scan base-package=“com.example” use-default-filters=“false”

context:include-filter type=“annotation” expression=“org.springframework.stereotype.Controller”/

</context:component-scan>

mvc:default-servlet-handler/

mvc:annotation-driven/

/jsp/

.jsp

5、配置mybatis-config.xml 文件信息和dbconfig.properties 数据库信息:

配置实体类在Mybatis中,配置分页的插件信息:使用分页的参数合理化,不会出现超出页面之外的访问和低于最少页面

mybatis-config.xml:

<?xml version="1.0" encoding="UTF-8" ?>

dbconfig.properties:

jdbc.jdbcUrl=jdbc:sqlserver://localhost:1433;database=ssm_crud

jdbc.driverClass=com.microsoft.sqlserver.jdbc.SQLServerDriver

jdbc.user=sa

jdbc.password=123456

6、配置applicationContext.xml文件信息:配置数据源信息,与mybatis整合的配置信息,事务控制

<?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:aop=“http://www.springframework.org/schema/aop”; xmlns:tx=“http://www.springframework.org/schema/tx”;

xsi:schemaLocation=“http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop.xsdhttp://www.springframework.org/schema/cachehttp://www.springframework.org/schema/cache/spring-cache.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsd”;>

context:component-scan base-package=“com.example”

context:exclude-filter type=“annotation” expression=“org.springframework.stereotype.Controller”/

</context:component-scan>

context:property-placeholder location=“classpath:/WEB-INF/dbconfig.properties”</context:property-placeholder>

aop:config

<aop:pointcut id=“txPoint” expression=“execution(* com.example.crud.service…*(…))”></aop:pointcut>

aop:advisor advice-ref=“txAdvice” pointcut-ref=“txPoint”</aop:advisor>

</aop:config>

tx:advice id=“txAdvice” transaction-manager=“transactionManager”

tx:attributes

tx:method name="*"/

tx:method name=“get*” read-only=“true”/

</tx:attributes>

</tx:advice>

7、添加jquery、bootstrap 前端js文件

作者:LarrYFinal
来源:CSDN
原文:https://blog.csdn.net/LarrYFinal/article/details/82557545
版权声明:本文为博主原创文章,转载请附上博文链接!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值