搭建的版本为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. python:删除文件及文件夹

    #!/usr/bin/python# -*- coding:utf-8 -*- import os import shutil os.remove(path) #删除文件shutil.rmtree(p ...

  2. QQ第三方登录(二)

    首先我们先来看一下我的目录 Connect2.1  是我们从下载的SDK,内容包含 其他文件在配置之后全部删除了! index.html 是我们点击登陆的页面(以下为html中的代码) <cen ...

  3. OpenGL 编程指南 (2)

    1.OpenGL对共享的边有严格的规定:1)共享边上的像素因为同事被两者所覆盖,因此不可能不受到光照计算的影响: 2)共享边上的像素值,不可能受到多于一个三角形的光照计算的影响. 2.多边形存在正面与 ...

  4. Suggestions On Setting LED Holiday Light

    We all like the cheerful glow of holiday lights, so the process goes seamless from start to finish. ...

  5. LoadRunner使用记录

    基本术语 性能测试--通过自动化的测试工具模拟多种正常.峰值以及异常负载条件来对系统的各项性能指标进行测试. 负载测试和压力测试都属于性能测试,两者可以结合进行. 负载测试,确定在各种工作负载下系统的 ...

  6. VC++编译选项

    -优化- /O1 最小化空间 minimize space /Op[-] 改善浮点数一致性 improve floating-pt consistency /O2 最大化速度 maximize spe ...

  7. Sobel边缘检测算法

    索贝尔算子(Sobel operator)主要用作边缘检测,在技术上,它是一离散性差分算子,用来运算图像亮度函数的灰度之近似值.在图像的任何一点使用此算子,将会产生对应的灰度矢量或是其法矢量 Sobe ...

  8. url中的参数加密

    有时候我们需要在地址栏传输一些信息,比如查询数据的时候,传一个参数location.href = "/admin/extract?name="+"参数aaa"’ ...

  9. hadoop学习笔记(十):hdfs在命令行的基本操作命令(包括文件的上传和下载和hdfs中的文件的查看等)

    hdfs命令行 ()查看帮助 hdfs dfs -help ()查看当前目录信息 hdfs dfs -ls / ()上传文件 hdfs dfs -put /本地路径 /hdfs路径 ()剪切文件 hd ...

  10. Linux服务器上实现数据库和图片文件的定时备份

    一. 1.首先创建一个目录,用于存放备份的数据   2.在该目录下创建两个子目录一个用于存放数据库的信息,一个用于存放图片资源       3.#数据库的备份 执行下面的命令    mysqldump ...