搭建的版本为jdk8,要求myeclipse版本至少是2015。

可以使用试用期限内的myeclipse,也可以找到有授权的机器进行操作。搭建好的项目框架可以直接移植到免费软件eclipse使用。或者直接购买myeclipse授权。

一、创建一个java web项目(略,这里是myeclipse特有功能创建,任何方式都可以)

二、下载相关jar包

1、spring

通过任何方式下载均可,可以在maven上搜索,也可以通过官网一步一步找。

下载地址为https://repo.spring.io/webapp/#/artifacts/browse/tree/General/libs-release-local/org/springframework/spring

下载:

wget https://repo.spring.io/libs-release-local/org/springframework/spring/5.1.7 .RELEASE/spring-5.1.7 .RELEASE-dist.zip

2、mybatis、mybatis-spring

下载方式同上。

3、所有添加jar如下,上面没有的单独寻找。这里包含的不是最小依赖,添加了一些常用的jar。

aopalliance-1.0.jar

aspectjweaver-1.9.5.jar

commons-dbcp2-2.2.0.jar

commons-logging-1.2.jar

commons-pool2-2.5.0.jar

ehcache-2.10.2.jar

jackson-annotations-2.9.8.jar

jackson-core-2.9.8.jar

jackson-databind-2.9.8.jar

log4j-1.2.17.jar

log4j-api-2.11.0.jar

log4j-core-2.11.0.jar

log4j-web-2.11.0.jar

mybatis-3.4.6.jar

mybatis-spring-1.3.2.jar

mysql-connector-java-5.1.47.jar

slf4j-api-1.7.7.jar

spring-aop-5.1.7.RELEASE.jar

spring-beans-5.1.7.RELEASE.jar

spring-context-5.1.7.RELEASE.jar

spring-context-support-5.1.7.RELEASE.jar

spring-core-5.1.7.RELEASE.jar

spring-expression-5.1.7.RELEASE.jar

spring-jcl-5.1.7.RELEASE.jar

spring-jdbc-5.1.7.RELEASE.jar

spring-orm-5.1.7.RELEASE.jar

spring-tx-5.1.7.RELEASE.jar

spring-web-5.1.7.RELEASE.jar

spring-webmvc-5.1.7.RELEASE.jar

三、添加spring支持

1、导入jar,单独spring需要6个jar,springmvc需要额外两个jar,一共8个(其中一个不在下载的压缩包内)。上面已经导入。

2、配置web文件

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="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="WebApp_ID" version="3.0">
<display-name>ssm-jdk8-s5.-m3.</display-name>
<listener>
<listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
</listener> <filter>
<filter-name>log4jServletFilter</filter-name>
<filter-class>org.apache.logging.log4j.web.Log4jServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>log4jServletFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>springDispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springDispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>

3、配置springmvc配置文件

spring-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <context:annotation-config />
<context:component-scan base-package="com.bunny.ssm8" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
<context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.RestController" />
</context:component-scan>
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json;charset=UTF-</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<mvc:resources location="/img/" mapping="/img/**" />
<mvc:resources location="/css/" mapping="/css/**" />
<mvc:resources location="/js/" mapping="/js/**" />
<mvc:default-servlet-handler/>
</beans> 

4、配置spring配置文件

applicationContext.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/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"> <context:annotation-config />
<context:component-scan base-package="com.bunny.ssm8">
</context:component-scan> <import resource="classpath*:spring-mybatis.xml"/> </beans>

四、整合mybatis

1、导入jar,如果单独mybatis应该是一个jar,然后整合需要2个。就是上面有mybatis字样的两个jar。

2、配置数据源信息

mybatis.properties

db.url=jdbc:mysql://127.0.0.1:3306/bunny?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
db.username=root
db.password=
db.dirverClass=com.mysql.jdbc.Driver

3、配置mybatis整合spring的配置文件

<import resource="classpath*:spring-mybatis.xml"/>这行代码应该是这一步才添加,上面一节是添加好的内容。

spring-mybatis.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/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"> <bean id="annotationPropertyConfigurerMybatis"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="locations">
<list>
<value>classpath:mybatis.properties</value>
</list>
</property>
</bean> <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${db.dirverClass}"></property>
<property name="url" value="${db.url}" />
<property name="username" value="${db.username}" />
<property name="password" value="${db.password}" />
<property name="initialSize" value="" />
<property name="minIdle" value="" />
<property name="maxTotal" value="" />
<property name="validationQuery" value="SELECT 1" />
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
</bean> <bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</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.bunny.ssm8.service.*.*(..))"/>
</aop:config>
<!-- mybatis -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:mybatis/mybatis-config.xml" />
<property name="mapperLocations" value="classpath:mybatis/mapper/*.xml" />
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.bunny.ssm8.dao" />
</bean>
</beans>

五、整合完毕

至此还需要把配置文件中涉及到的所有文件夹路径都创建好,否则报错。然后可以开始按照配置文件中的要求进行开发。

代码地址:

svn://47.105.188.20/kitty/2、code/ssm-jdk8-s5.1-m3.4  用户名密码: reader reader


喵星之旅-狂奔的兔子-myeclipse搭建ssm的更多相关文章

  1. 喵星之旅-狂奔的兔子-基于docker的rabbitmq安装

    docker安装参考:喵星之旅-狂奔的兔子-docker安装和基本使用 一.查询镜像名称 由于我们要安装的是有web管理页面的,不能直接拉取,需要指定版本. 登录docker仓库查询:https:// ...

  2. 喵星之旅-狂奔的兔子-docker安装和基本使用

      一.前提条件 目前,CentOS 仅发行版本中的内核支持 Docker. 位.系统内核版本为 3.10 以上. 位系统.参考喵星之旅-狂奔的兔子-linux安装 二.CentOS 7下安装 Doc ...

  3. 喵星之旅-狂奔的兔子-rabbitmq的java客户端使用入门

    一.简介 RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件). 消息队列都涉及的生产者消费者模型,不做详解,本文只作为快速使用的参考文档. 消息队列主要有点 ...

  4. 喵星之旅-狂奔的兔子-centos7一键安装redmine

    一.安装环境 CentOS-7-x86_64-DVD-1908.iso 二.获取安装文件 从官网获取,在下载页面提供了多种安装,最下方是一键安装版本,里面有两种选择,一个是安装包,一个是虚拟机硬盘文件 ...

  5. 喵星之旅-狂奔的兔子-centos7安装MySQL 5.5

    安装环境:https://www.cnblogs.com/kittybunny/p/12296078.html 一.下载安装文件 下载地址 https://downloads.mysql.com/ar ...

  6. 喵星之旅-狂奔的兔子-linux安装

    一.前言 本文演示虚拟机安装,和真机区别可能在网卡驱动上有差异. 真机环境:CentOS Linux release 7.6.1810 (Core) 虚拟机(虽然centos系统自带虚拟机软件,但是习 ...

  7. 喵星之旅-狂奔的兔子-redis使用

    一.命令行使用 redis大概有200多命令,这里只是入门级别,列举了一些非常常见的内容,如果这些会了就可以开启redis进一步学习了. 1.登录数据库 我们需要知道ip地址.端口号.密码(如果有). ...

  8. 喵星之旅-狂奔的兔子-svn安装及使用

    一.服务端安装配置 1.安装svn 创建版本库并配置 以root用户登录,或者具有sudo权限的用户,这里选择root. yum install subversion 都选择y 2.创建版本库并配置 ...

  9. 喵星之旅-狂奔的兔子-redis安装

    一.前置条件 服务器版本CentOS-8-x86_64-1905-dvd1,在此版本上安装最新版redis.centos7以上版本都可以,不建议6以前的版本. 二.下载redis,并上传到服务器 登录 ...

随机推荐

  1. C#WinForm 实现登录界面验证码功能(区分大小写+不区分大小写)

    原文:C#WinForm 实现登录界面验证码功能(区分大小写+不区分大小写) 文章来自:https://blog.csdn.net/IT_xiao_guang_guang/article/detail ...

  2. Vue.js ---Hello---1

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  3. 【Python】random库

    种子相同,随机数相同

  4. win10下安装es

    1.安装前提 windows下已经安装好了jdk8的版本 2.下载ElasticSearch https://www.elastic.co/cn/downloads/elasticsearch#ga- ...

  5. 松软科技web教程:JavaScript HTML DOM 事件监听器

    addEventListener() 方法 实例 添加当用户点击按钮时触发的事件监听器: document.getElementById("myBtn").addEventList ...

  6. mysql(5):主从复制和分库分表

    主从复制集群 概念:主从复制是指数据可以从一个MySQL数据库服务器主节点复制到一个或多个从节点. 使用场景: 读写分离:使用主从复制,让主库负责写,从库负责读,这样,即使主库出现了锁表的情景,通过读 ...

  7. adb+tcpdump手机抓包过程出现的报错及解决方法

    tcpdump下载:https://www.androidtcpdump.com/android-tcpdump/downloads 1.夜神模拟器连接不上adb D:1手机木马取证\android- ...

  8. [C++] JsonCPP 的使用 完整配置过程

    最近准备开发一个程序 需要用到C++ 解析json 原始的C++解析json是不现实的 自己也写不出来json解析方法(主要是不靠谱) 所以找到了jsoncpp 这个库 但是... 因为各种原因 配置 ...

  9. mysql分组,然后组内排序取最新的一条

    参照: https://blog.csdn.net/qq_16504067/article/details/78589232 https://www.cnblogs.com/w1441639547/p ...

  10. 题解【CodeForces171C】A Piece of Cake

    Description 给你\(n\)个数,求出\(\sum_{i=1}^{n} a_{i}\times i\qquad\) Input 共\(n + 1\)个数,分别为\(n\)和\(n\)个数\( ...