基于SSM框架配置多数据源
项目基于ssm + maven,通过注解可以实现自动切换数据源。
一、pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.multipleDataSource</groupId>
<artifactId>multipleDataSource</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging> <name>multipleDataSource Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url> <properties>
<org.springframework.version>4.2.4.RELEASE</org.springframework.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<jackson.version>2.8.5</jackson.version> <org.mybatis.version>3.4.1</org.mybatis.version>
<org.mybatis.spring.version>1.3.0</org.mybatis.spring.version>
</properties> <dependencies>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>7.0.64</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${org.springframework.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
</dependency> <dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.3</version>
</dependency> <dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${org.mybatis.spring.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${org.mybatis.version}</version>
</dependency> <dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.11</version>
</dependency> <dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.12</version>
</dependency> <dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
<!--<scope>runtime</scope>-->
</dependency> <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.2</version>
<scope>compile</scope>
</dependency> <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency> <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
</dependency> <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency> <dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency> <dependency>
<groupId>com</groupId>
<artifactId>druid</artifactId>
<version>1.0.9</version>
</dependency> <dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency> <dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency> <!-- jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency> <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies> <build>
<finalName>multipleDataSource</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
二、web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" > <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_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Archetype Created Web Application</display-name> <!--过滤器,转码用的 /* 拦截所有路径-->
<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>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!--扫描springMVC配置文件-->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:ApplicationContext.xml
</param-value>
</init-param>
<!--设置优先级最高级-->
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
三、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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!--注解配置-->
<context:annotation-config/> <mvc:annotation-driven >
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter"/>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
</mvc:message-converters>
</mvc:annotation-driven> <!--扫描controller和service层-->
<context:component-scan base-package="com.multipleDataSource.controller,com.multipleDataSource.service" annotation-config="true"/> <!--<context:annotation-config/>-->
<aop:aspectj-autoproxy/> <!-- jdbc.properties文件路径 -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value> </list>
</property> <!--value="classpath:/com/ningpai/web/config/jdbc.properties" />-->
</bean> <!-- 数据源的配置 -->
<bean id="dataSource1" class="com.alibaba.druid.pool.DruidDataSource"
init-method="init" destroy-method="close">
<property name="driverClassName" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean> <!--第二个数据源-->
<bean name="dataSource2" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<property name="driverClassName" value="${jdbc.driver_2}"/>
<property name="url" value="${jdbc.url_2}"/>
<property name="username" value="${jdbc.username_2}"/>
<property name="password" value="${jdbc.password_2}"/>
</bean> <!-- 下面的是切换数据库的自定义类 -->
<bean id="multipleDataSource" class="com.multipleDataSource.common.DynamicDataSource">
<property name="targetDataSources">
<map key-type="java.lang.String">
<entry key="dataSource1" value-ref="dataSource1"></entry>
<entry key="dateSource2" value-ref="dataSource2"></entry>
</map>
</property>
<property name="defaultTargetDataSource" ref="dataSource1"></property>
</bean> <!--事务相关控制-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="multipleDataSource"/>
</bean>
<!-- 使用@Transactional进行声明式事务管理需要声明下面这行 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" order="2"/> <!-- MyBatis sqlSessionFactory 配置 mybatis-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="multipleDataSource"/>
<property name="mapperLocations" value="classpath*:mapper/*Mapper.xml"/>
</bean>
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory"/>
</bean> <!-- JdbcTemplate使用动态数据源的配置 -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource">
<ref bean="multipleDataSource"/>
</property>
</bean> <bean name="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.multipleDataSource.dao"/>
</bean> <!--前缀和后缀配置-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean> <!-- 激活自动代理功能 -->
<aop:aspectj-autoproxy proxy-target-class="true"/> <bean id="dataSourceAspect" class="com.multipleDataSource.common.aspect.DataSourceAspect"/> <aop:config>
<aop:aspect id="c" ref="dataSourceAspect">
<aop:pointcut id="tx" expression="execution(* com.multipleDataSource.dao..*.*(..))"/>
<aop:before pointcut-ref="tx" method="before"/>
</aop:aspect>
</aop:config>
</beans>
四、jdbc.properties
jdbc.url=jdbc:mysql://localhost:3306/user?useUnicode=true&characterEncoding=UTF-8&relaxAutoCommit=true&zeroDateTimeBehavior=convertToNull
jdbc.username=root
jdbc.password=123456
jdbc.driver=com.mysql.jdbc.Driver jdbc.driver_2=com.mysql.jdbc.Driver
jdbc.url_2=jdbc:mysql://localhost:3306/city?useUnicode=true&characterEncoding=UTF-8&relaxAutoCommit=true&zeroDateTimeBehavior=convertToNull
jdbc.username_2=root
jdbc.password_2=123456
五、自定义DynamicDataSource 类
实现自动切换数据源,通过自定义DataSource注解,切面管理。
1、数据源上下文 DataSourceContextHolder
package com.multipleDataSource.common; /**
* 数据源上下文类
* @author zhongtao on 2018/5/5
*/
public class DataSourceContextHolder {
private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>(); public static void setDbType(String dbType) {
contextHolder.set(dbType);
} public static String getDbType() {
return ((String) contextHolder.get());
} public static void clearDbType() {
contextHolder.remove();
}
}
2、DynamicDataSource 类
package com.multipleDataSource.common; import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; /**
* 动态转换数据源
* @author zhongtao on 2018/5/5
*/
public class DynamicDataSource extends AbstractRoutingDataSource {
@Override
protected Object determineCurrentLookupKey() {
return DataSourceContextHolder.getDbType();
}
}
3、DataSource 注解类
package com.multipleDataSource.annotation; import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; /**
* 注解类
* @author zhongtao on 2018/5/7
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface DataSource {
String value();
}
4、DataSourceAspect 切面管理
package com.multipleDataSource.common.aspect; import com.multipleDataSource.annotation.DataSource;
import com.multipleDataSource.common.DataSourceContextHolder;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature; import java.lang.reflect.Method; /**
* 数据源切面类
*
* @author zhongtao on 2018/5/7
*/
public class DataSourceAspect {
public void pointCut() {
} @Before(value = "pointCut()")
public void before(JoinPoint point) {
//拦截的实体类
Object target = point.getTarget();
//拦截的方法名
String methodName = point.getSignature().getName();
//接口
Class<?>[] interfaces = target.getClass().getInterfaces();
//拦截的放置参数类型
Class<?>[] parameterTypes = ((MethodSignature) point.getSignature()).getMethod().getParameterTypes(); try {
Method method = interfaces[0].getMethod(methodName, parameterTypes);
if (method != null && method.isAnnotationPresent(DataSource.class)) {
DataSource data = method.getAnnotation(DataSource.class);
DataSourceContextHolder.setDbType(data.value());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
5、数据源类型
package com.multipleDataSource.common; /**
* 数据源类型 需要和ApplicationContext.xml中的multipleDataSource下的key相同
* @author zhongtao on 2018/5/5
*/
public class DataSourceType {
public static final String MYSQL1 = "dataSource1"; public static final String MYSQL2 = "dateSource2";
}
六、pojo类
1、User类
package com.multipleDataSource.pojo; /**
* @author zhongtao on 2018/5/7
*/
public class User { private Integer id; /**
* 用户名
*/
private String userName; /**
* 描述
*/
private String description; private City city; public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} public String getUserName() {
return userName;
} public void setUserName(String userName) {
this.userName = userName;
} public String getDescription() {
return description;
} public void setDescription(String description) {
this.description = description;
} public City getCity() {
return city;
} public void setCity(City city) {
this.city = city;
}
}
2、City类
package com.multipleDataSource.pojo; /**
* @author zhongtao on 2018/5/7
*/
public class City {
/**
* 城市编号
*/
private Long id; /**
* 省份编号
*/
private Long provinceId; /**
* 城市名称
*/
private String cityName; /**
* 描述
*/
private String description; public Long getId() {
return id;
} public void setId(Long id) {
this.id = id;
} public Long getProvinceId() {
return provinceId;
} public void setProvinceId(Long provinceId) {
this.provinceId = provinceId;
} public String getCityName() {
return cityName;
} public void setCityName(String cityName) {
this.cityName = cityName;
} public String getDescription() {
return description;
} public void setDescription(String description) {
this.description = description;
}
}
3、ResultVo类
package com.multipleDataSource.pojo; /**
* @author zhongtao on 2018/5/7
*/
public class ResultVo<T> { private boolean success = true;
private String code ="0000";
private String msg;
private T data; public boolean isSuccess() {
return success;
} public void setSuccess(boolean success) {
this.success = success;
} public String getCode() {
return code;
} public void setCode(String code) {
this.code = code;
} public String getMsg() {
return msg;
} public void setMsg(String msg) {
this.msg = msg;
} public T getData() {
return data;
} public void setData(T data) {
this.data = data;
}
}
七、controller层
1、UserController类
package com.multipleDataSource.controller; import com.multipleDataSource.pojo.ResultVo;
import com.multipleDataSource.pojo.User;
import com.multipleDataSource.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView; /**
* @author zhongtao on 2018/5/7
*/
@Controller
public class UserController { @Autowired
private UserService userService; /**
* 获取数据
* @param userName
* @return
*/
@RequestMapping(value = "/getData")
@ResponseBody
public ResultVo getName(@RequestParam(value = "userName") String userName) {
ResultVo<Object> resultVo = new ResultVo<>();
if (userName==null){
resultVo.setMsg("用户名错误");
resultVo.setCode("0001");
}else {
User user = userService.findByName(userName);
if(!StringUtils.isEmpty(user)){
resultVo.setMsg("测试成功");
resultVo.setData(user);
}
}
return resultVo;
}
}
八、service层
1、UserService层
package com.multipleDataSource.service; import com.multipleDataSource.pojo.User; /**
* 用户类接口
* @author zhongtao on 2018/5/7
*/
public interface UserService { /**
* 根据用户名获取用户信息,包括从库的地址信息
*
* @param userName
* @return
*/
User findByName(String userName);
}
2、UserServiceImpl
package com.multipleDataSource.service.impl; import com.multipleDataSource.dao.CityDao;
import com.multipleDataSource.dao.UserDao;
import com.multipleDataSource.pojo.City;
import com.multipleDataSource.pojo.User;
import com.multipleDataSource.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; /**
* @author zhongtao on 2018/5/7
*/
@Service
public class UserServiceImpl implements UserService{
@Autowired
private UserDao userDao; // 数据源1 @Autowired
private CityDao cityDao; // 数据源2 @Override
public User findByName(String userName) {
User user = userDao.findByName(userName);
City city = cityDao.findByName("成都市");
user.setCity(city);
return user;
}
}
九、dao层
1、UserDao类
package com.multipleDataSource.dao; import com.multipleDataSource.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; /**
* @author zhongtao on 2018/5/7
*/
@Mapper
public interface UserDao { /**
* 根据用户名获取用户信息 默认数据源不用加 DataSource标签
*
* @param userName
* @return
*/
User findByName(@Param("userName") String userName);
}
2、CityDao类
package com.multipleDataSource.dao; import com.multipleDataSource.annotation.DataSource;
import com.multipleDataSource.common.DataSourceType;
import com.multipleDataSource.pojo.City;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; /**
* @author zhongtao on 2018/5/7
*/
@Mapper
public interface CityDao {
/**
* 根据城市名称,查询城市信息 需要加上 DataSource标签,自动切换数据源
*
* @param cityName 城市名
*/
@DataSource(DataSourceType.MYSQL2)
City findByName(@Param("cityName") String cityName);
}
十、mapper文件
1、UserMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.multipleDataSource.dao.UserDao">
<resultMap id="BaseResultMap" type="com.multipleDataSource.pojo.User">
<result column="id" property="id" />
<result column="user_name" property="userName" />
<result column="description" property="description" />
</resultMap> <parameterMap id="User" type="com.multipleDataSource.pojo.User"/> <sql id="Base_Column_List">
id, user_name, description
</sql> <select id="findByName" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List" />
from user
where user_name = #{userName}
</select>
</mapper>
2、CityMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.multipleDataSource.dao.CityDao">
<resultMap id="BaseResultMap" type="com.multipleDataSource.pojo.City">
<result column="id" property="id" />
<result column="province_id" property="provinceId" />
<result column="city_name" property="cityName" />
<result column="description" property="description" />
</resultMap> <parameterMap id="City" type="com.multipleDataSource.pojo.City"/> <sql id="Base_Column_List">
id, province_id, city_name, description
</sql> <select id="findByName" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="Base_Column_List" />
from city
where city_name = #{cityName}
</select> </mapper>
十一、测试
1、网址输入
2、结果显示
基于SSM框架配置多数据源的更多相关文章
- 一款基于SSM框架技术的全栈Java web项目(已部署可直接体验)
概述 此项目基于SSM框架技术的Java Web项目,是全栈项目,涉及前端.后端.插件.上线部署等各个板块,项目所有的代码都是自己编码所得,每一步.部分都有清晰的注释,完全不用担心代码混乱,可以轻松. ...
- Java基于ssm框架的restful应用开发
Java基于ssm框架的restful应用开发 好几年都没写过java的应用了,这里记录下使用java ssm框架.jwt如何进行rest应用开发,文中会涉及到全局异常拦截处理.jwt校验.token ...
- 基于SSM框架的JavaWeb通用权限管理系统
- - ->关注博主公众号[C you again],获取更多IT资源(IT技术文章,毕业设计.课程设计系统源码,经典游戏源码,HTML网页模板,PPT.简历模板,!!还可以投稿赚钱!!,点击查 ...
- SSM框架之多数据源配置
多数据源的应用场景:主要是数据库拆分后,怎样让多个数据库结合起来来达到业务需求. SSM框架(Spring+SpringMVC+MyBatis(MyBatis-Plus))是目前最常用的,此次仍然是m ...
- ssm框架配置过程
1.pom.xml配置 1.1<build>标签中配置<plugins>和<resources>,即插件和资源文件 1.2 <properties>标签 ...
- Python基于Flask框架配置依赖包信息的项目迁移部署小技巧
一般在本机上完成基于Flask框架的代码编写后,如果有接口或者数据操作方面需求需要把代码部署到指定服务器上. 一般情况下,使用Flask框架开发者大多数都是选择Python虚拟环境来运行项目,不同的虚 ...
- 基于SSM框架贺州学院校园二手交易平台设计与实现
前言 这个是我当时的毕业论文,分享出来,给同学们参考. 绪论 随着中国新四大发明的诞生,网购成了千千万万网友们购物的新方式,新的购物方式促进商业的发展,但随着人们生活水平的提高,许多新购置的物品用了没 ...
- pageoffice实现网页打开编辑保存word文档(基于SSM框架)
pageoffice是一款网页集成word.excel...等office工具 并不免费,但可以试用练习 SSM框架搭建过程就省略了 注意:由于谷歌/火狐升级,不支持插件嵌入,建议使用POBrowse ...
- 【项目笔记】完成一个基于SSM框架的增删改查的模块后总结的问题
最近为了准备新工作重新摸出了SSM框架,同时从0学习了JQuery,终于用一周做完了一个包括增删改查的模块(主要是属性太多了,其中一个类50+,复制粘贴耗时). 从中特意记下了几个遇到的问题,总结一下 ...
随机推荐
- Wannafly挑战赛26题解
为啥混进了几道不是魔禁的题--出题人太不敬业了-- 传送门 \(A\) 御坂网络 为啥没有番外个体和整体意志呢 暴力模拟就好了,这个要是都打错我干脆滚回去学文化课算了 //minamoto #incl ...
- Jmeter非GUI运行,生成html报告
一.JMete执行方式 JMeter执行方式有2种,一种是GUI模式,一种是非GUI模式.GUI模式就是界面模式,非GUI模式就是命令行模式.界面模式主要用来编写和调试脚本用的,项目的真正执行最好是采 ...
- sqli-labs lession 5 之盲注型SQL入门
本文作者:Mochazz 如果所查询的用户id在数据库中,可以发现页面显示”You are in”,而不像前4关那样会显示出具体的账号密码. 如果sql语句查询结果不存在,则不会显示”You are ...
- Substr函数助你免杀php脚本
主要利用substr函数和url编解码 本文作者:i春秋签约作家Laimooc 1]安全狗: 新研究的php脚本木马:最新版安全狗扫描如下: 成功看到:扫描已完成,未发现网页木马以及其他威胁(开心吗, ...
- C++与C的区别一
1. C++风格数组初始化: #include <iostream> #include <array> using namespace std; void main() { / ...
- JavaScript的几种(原型)继承
定义Foo,Bar 其中,Bar继承Foo a是Bar的实例,包含有Foo和Bar的函数和属性: function Foo(name) { this.name = name; } Foo.protot ...
- 基于.Net平台C#的微信网页版API
git上有很多类似的项目,但大多都是python和js的,为了便于.Net windows平台的使用,我重构了一个.Net版本的,已整理开源 https://github.com/leestar54/ ...
- 不依赖JQuery的入门Ajax代码
今天看了head first ajax这本书里ajax的实例,讲的很好,这本书觉着很不错,推荐下. Ajax (Asynchronous Javascript and XML)即异步Javascrip ...
- redux在componentDidMount中出现的问题 --- state 不变
遇到这样一个问题: 在组件的componentDidMount中,我需要使用到redux中存储的某个状态. 但是有趣的是,当我再render中使用相同的状态时,状态会改变,但是在conponentDi ...
- RealVNC
使用Linux服务器,在一般情况下是不太用桌面环境的.不过现在我想着开发用Linux,如使用Pycharm这种IDE,还是很方便的.这样还是需要桌面环境的,然而我们位置不多,就将服务器的屏幕摘下了,那 ...