小程序开发之后台SSM环境搭建(一)
1、新建web项目
打开eclipse,选择file-->New-->Dynamic web Project ,填写项目名字,一直点击next,勾选Generate web.xml deployment descriptor,点击Finish即可。
2、引入SSM所需jar包
链接:https://pan.baidu.com/s/1h0i79ieER5K-s1YoD55xzg 密码:npze
3、新建项目目录结构

4、SSM配置文件
4-1、jdbc.properties
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/luolan?useUnicode=true&characterEncoding=utf-8
jdbc.username=root
jdbc.password=123456
4-2、applicationContext-dao.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-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<!-- 引入jdbc配置文件 -->
<context:property-placeholder location="classpath:jdbc.properties"/>
<!-- 配置数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driver}"></property>
<property name="jdbcUrl" value="${jdbc.url}"></property>
<property name="user" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
<!-- 配置sqlSessionFactory spring mybatis整合-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!-- 注入数据源 -->
<property name="dataSource" ref="dataSource"></property>
<!-- 扫描mybatis核心配置文件 -->
<property name="configLocation" value="classpath:mybatis.xml"></property>
<!-- 自动使用别名 -->
<property name="typeAliasesPackage" value="com.luolan.entity"></property>
<!-- 扫描mapper映射文件 -->
<property name="mapperLocations" value="classpath:com/luolan/mapping/*.xml"></property>
</bean>
<!-- 扫描DAO接口包 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 注入sqlSessionFactory -->
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
<!-- 扫描DAO接口包 -->
<property name="basePackage" value="com.luolan.dao"></property>
</bean>
</beans>
4-3、applicationContext-web.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: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.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- 开启注解映射的支持 -->
<mvc:annotation-driven />
<!-- 允许对静态资源的访问 -->
<mvc:default-servlet-handler/>
<!-- 配置视图解析器 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- 设置包扫描注解 -->
<context:component-scan base-package="com.luolan.controller"></context:component-scan>
<!-- 开启注解 -->
<context:annotation-config></context:annotation-config>
</beans>
4-4、applicationContext-service.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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
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/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- 扫描service包 -->
<context:component-scan base-package="com.luolan.serviceImpl"></context:component-scan>
<!-- 配置事物管理器 -->
<bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager" id="transactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 事物采用注解的方式进行 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>
4-5、mybatis.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<!-- 使用jdbc的getGeneratedKeys获取的数据库自增主键值 -->
<setting name="useGeneratedKeys" value="true" />
<!-- 使用列别名替换列名 -->
<setting name="useColumnLabel" value="true" />
<!-- 开启驼峰命名法则 -->
<setting name="mapUnderscoreToCamelCase" value="true" />
</settings>
</configuration>
4-6、web.xml
<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>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/applicationContext-*.xml</param-value>
</context-param>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/applicationContext-web.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
5、测试
TestController.java
@Controller
@RequestMapping(value="/test")
public class TestController {
@ResponseBody
@RequestMapping(value="/index",method = RequestMethod.GET)
public Integer test(){
return 1;
}
}
运行结果如图所示:执行成功

至此,SSM框架搭建成功。
小程序开发之后台SSM环境搭建(一)的更多相关文章
- 小程序开发之后台mybatis逆向工程(二)
上一节搭建好了SSM后台框架,这一节将根据表结构创建实体及映射文件以及mapper接口.如果表过多,会很麻烦,所以mybatis提供了逆向工程来解决这个问题. 上一节 SSM搭建后台管理系统 逆向工程 ...
- 跟我一起,利用bitcms内容管理系统从0到1学习小程序开发:一、IIS下SSL环境搭建
缘起 1.从事互联网十来年了,一直想把自己的从事开发过程遇到的问题给写出来,分享给大家.可是可是这只是个种想法,想想之后就放下了,写出来的类文章是少之又少.古人说无志之人常立志,有志之人立长志.今天, ...
- 微信小程序开发系列一:微信小程序的申请和开发环境的搭建
我最近也刚刚开始微信小程序的开发,想把我自学的一些心得写出来分享给大家. 这是第一篇,从零开始学习微信小程序开发.主要是小程序的注册和开发环境的搭建. 首先我们要在下列网址申请一个属于自己的微信小程序 ...
- TODO:小程序开发环境搭建
TODO:小程序开发环境搭建 1.第一步当然是要先注册小程序了 2.登录到小程序 a)完善小程序信息,如名称,图标,描述 3.绑定开发者 4.获取AppID,并设置服务器信息 5.下载并安装开发者工具 ...
- 小程序开发之搭建WebSocket的WSS环境(Apache+WorkerMan框架+PHP)
最近公司的一个IoT项目用到了小程序的WSS协议环境,现在把整个的搭建开发过程分享给大家. 这里我们用的是WorkerMan框架,服务器是CentOS,Web服务器是Apache,开发语言是PHP. ...
- 建站集成软件包 XAMPP搭建后台系统与微信小程序开发
下载安装XAMPP软件,运行Apache和MySQL 查看项目文件放在哪个位置可以正常运行 然后访问localhost即可 下载weiphp官网的weiapp(专为微信小程序开发使用)放在htdocs ...
- 微信小程序开发环境搭建
关注,QQ群,微信应用号社区 511389428 微信小程序可谓是今天最火的一个名词了,一经出现真是轰炸了整个开发人员,当然很多App开发人员有了一个担心,微信小程序的到来会不会给移动端App带来一个 ...
- Java开发学习心得(一):SSM环境搭建
目录 Java开发学习心得(一):SSM环境搭建 1 SSM框架 1.1 Spring Framework 1.2 Spring MVC Java开发学习心得(一):SSM环境搭建 有一点.NET的开 ...
- 微信小程序开发环境安装以及相关设置配置
微信小程序开发环境安装以及相关设置配置 一.安装 软件名称:wechat_devtools_1.02.1907232_x64 软件安装地址:https://developers.weixin.qq.c ...
随机推荐
- Day1 模拟赛 题解
T1:首先你要发现,对于任意一个奇数i,i xor (i-1)=1; 那么我们可以将答案转化为统计有多少个1相互异或起来: 所以答案就那么几种: 如果你用的数位DP,只能说明你太高估day1T1了: ...
- phpQuery简介
接上一篇,使用 Snoopy 抓取回来网页之后,需要解析网页中的元素,但是对于 https://www.cnblogs.com/hellowzd/p/5163276.html
- centos编译安装python3怎么做?
照着我的博客操作 你一定能成功的!因为我就是一步一步的做出来的,虽然只有文档,但是希望你能有耐心!!!! 编译安装难么麻烦,为什么还要编译安装? 那我告诉你想进步就要折腾!你习惯了windows的安装 ...
- Java EE javax.servlet ServletContainerInitializer接口
ServletContainerInitializer接口 public interface ServletContainerInitializer 一.介绍 该接口,允许在 web 应用程序的启动阶 ...
- asp.net 12 AJAX
Javascript:ajax Ajax:get <%@ Page Language="C#" AutoEventWireup="true" CodeBe ...
- O033、Terminate Instance 操作详解
参考https://www.cnblogs.com/CloudMan6/p/5486066.html 本节通过日志详细分析 Nova Terminate 操作.Terminate 操作就是删除 i ...
- 帝国cms 通过栏目获取某个栏目的详情
当是某个栏目的时候,获取另外一个栏目下第一篇文章的详情,否则获取当前栏目下第一篇文章的详情 <?php $classid = $GLOBALS['navclassid']; if($classi ...
- vue滚动+滑动删除标记(移动端)仿qq/微信
安装组件 "vue-touch": "^2.0.0-beta.4", main.js引入 import VueTouch from 'vue-touch' Vu ...
- U盘被识别但不显示盘符怎么样才能解决?
很多朋友在将U盘插入电脑后,会发现右下角的任务栏虽然出现了U盘的图标,但是在我的电脑中并没有显示出U盘的盘符,也就无法继续对U盘进行操作.遇到这种情况该怎么办呢?下面好系统U盘启动就告诉大家相应的解决 ...
- current status of the installation and the internationalization of Samba 3.0
Only about 8 months from release of Samba 3.0.0, there is beginning to be the transition from 2.2.x. ...