喵星之旅-狂奔的兔子-myeclipse搭建ssm
搭建的版本为jdk8,要求myeclipse版本至少是2015。
可以使用试用期限内的myeclipse,也可以找到有授权的机器进行操作。搭建好的项目框架可以直接移植到免费软件eclipse使用。或者直接购买myeclipse授权。
一、创建一个java web项目(略,这里是myeclipse特有功能创建,任何方式都可以)
二、下载相关jar包
1、spring
通过任何方式下载均可,可以在maven上搜索,也可以通过官网一步一步找。
下载:
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的更多相关文章
- 喵星之旅-狂奔的兔子-基于docker的rabbitmq安装
		
docker安装参考:喵星之旅-狂奔的兔子-docker安装和基本使用 一.查询镜像名称 由于我们要安装的是有web管理页面的,不能直接拉取,需要指定版本. 登录docker仓库查询:https:// ...
 - 喵星之旅-狂奔的兔子-docker安装和基本使用
		
一.前提条件 目前,CentOS 仅发行版本中的内核支持 Docker. 位.系统内核版本为 3.10 以上. 位系统.参考喵星之旅-狂奔的兔子-linux安装 二.CentOS 7下安装 Doc ...
 - 喵星之旅-狂奔的兔子-rabbitmq的java客户端使用入门
		
一.简介 RabbitMQ是实现了高级消息队列协议(AMQP)的开源消息代理软件(亦称面向消息的中间件). 消息队列都涉及的生产者消费者模型,不做详解,本文只作为快速使用的参考文档. 消息队列主要有点 ...
 - 喵星之旅-狂奔的兔子-centos7一键安装redmine
		
一.安装环境 CentOS-7-x86_64-DVD-1908.iso 二.获取安装文件 从官网获取,在下载页面提供了多种安装,最下方是一键安装版本,里面有两种选择,一个是安装包,一个是虚拟机硬盘文件 ...
 - 喵星之旅-狂奔的兔子-centos7安装MySQL 5.5
		
安装环境:https://www.cnblogs.com/kittybunny/p/12296078.html 一.下载安装文件 下载地址 https://downloads.mysql.com/ar ...
 - 喵星之旅-狂奔的兔子-linux安装
		
一.前言 本文演示虚拟机安装,和真机区别可能在网卡驱动上有差异. 真机环境:CentOS Linux release 7.6.1810 (Core) 虚拟机(虽然centos系统自带虚拟机软件,但是习 ...
 - 喵星之旅-狂奔的兔子-redis使用
		
一.命令行使用 redis大概有200多命令,这里只是入门级别,列举了一些非常常见的内容,如果这些会了就可以开启redis进一步学习了. 1.登录数据库 我们需要知道ip地址.端口号.密码(如果有). ...
 - 喵星之旅-狂奔的兔子-svn安装及使用
		
一.服务端安装配置 1.安装svn 创建版本库并配置 以root用户登录,或者具有sudo权限的用户,这里选择root. yum install subversion 都选择y 2.创建版本库并配置 ...
 - 喵星之旅-狂奔的兔子-redis安装
		
一.前置条件 服务器版本CentOS-8-x86_64-1905-dvd1,在此版本上安装最新版redis.centos7以上版本都可以,不建议6以前的版本. 二.下载redis,并上传到服务器 登录 ...
 
随机推荐
- TCP的粘包和拆包问题及解决
			
前言 TCP属于传输层的协议,传输层除了有TCP协议外还有UDP协议.那么UDP是否会发生粘包或拆包的现象呢?答案是不会.UDP是基于报文发送的,从UDP的帧结构可以看出,在UDP首部采用了16bit ...
 - 三、linux环境的搭建1(oracle、ssh、jdk、mysql、samba、tomcat)
			
linux环境的搭建1(oracle.ssh.jdk.mysql.samba.tomcat) 网络配置 方案一 tip 1 使用ifconfig : ifconfig eth0 新ip 然后编辑/ ...
 - adb server version (xx) doesn't match this client (xx); killing...
			
问题 查看AndroidSDK的adb版本 查看模拟器adb的版本号 安装路径/bin目录下的 nox_adb.exe 将AndroidSDK的adb复制出来,重命名为nox_adb.exe,覆盖模拟 ...
 - 3ds Max File Format (Part 5: How it all links together; ReferenceMaker, INode)
			
At this point, you should start to familiarize yourself a bit with the publicly available 3ds Max AP ...
 - selenium爬去数据+存储
			
1 爬去数据代码 #coding=utf-8 from selenium import webdriver from selenium.webdriver.common.by import By fr ...
 - 利用Cadence PCB SI分析特性阻抗变化因素
			
1.概要 在进行PCB SI的设计时,理解特性阻抗是非常重要的.这次,我们对特性阻抗进行基础说明之外,还说明Allegro的阻抗计算原理以及各参数和阻抗的关系. 2.什么是特性阻抗? 2.1 传送线路 ...
 - 自动构建自己的ASP.NET Core基础镜像
			
在开发过程中,我们可以根据自身情况来定制自己的基础镜像,以便加快CI\CD构建速度以及提高开发体验.这里我们就以ASP.NET Core的基础镜像为例来进行讲解. 本次教程代码见开源库:https:/ ...
 - 大数据-sparkSQL
			
SparkSQL采用Spark on Hive模式,hive只负责数据存储,Spark负责对sql命令解析执行. SparkSQL基于Dataset实现,Dataset是一个分布式数据容器,Datas ...
 - python面试的100题(3)
			
3.输入日期, 判断这一天是这一年的第几天? import datetime def dayofyear(): year = input("请输入年份: ") month = in ...
 - python console的命令执行
			
命令 from app01 import models models.UserInfo.objects.all()查询出所有内容