springboot mybatis整合redis


pom.xml



	4.0.0

	com.sdfsaf.kdb
	springboot-mytest
	0.0.1-SNAPSHOT
	jar

	springboot-mytest
	Demo project for Spring Boot

	
		org.springframework.boot
		spring-boot-starter-parent
		1.4.7.RELEASE
		 
	

	
		UTF-8
		UTF-8
		1.8
	

	
		
			org.springframework.boot
			spring-boot-starter-web
		

		
			org.springframework.boot
			spring-boot-starter-test
			test
		

		
		
			com.jolbox
			bonecp-spring
			0.8.0.RELEASE
		
		
			org.springframework.boot
			spring-boot-starter-web
		
		
		
			mysql
			mysql-connector-java
		
		

		
			com.github.pagehelper
			pagehelper
			4.1.0
		
		
			org.mybatis.spring.boot
			mybatis-spring-boot-starter
			1.1.1
		

		
			org.springframework.boot
			spring-boot-starter-redis
		

		
			net.sf.json-lib
			json-lib
			2.1
			jdk15
		


	

	
		
			
				org.springframework.boot
				spring-boot-maven-plugin
			
		
	




application.properties

mybatis.mapper-locations=classpath:mapper/*Mapper.xml
mybatis.config-location=classpath:mapper/config/mybatis-config.xml

spring.datasource.url=jdbc:mysql://localhost:3306/esky_expert?useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driverClassName=com.mysql.jdbc.Driver

spring.redis.host=127.0.0.1
spring.redis.port=6379



mybatis-config.xml




	
		
	



UserMapper.xml





  
 
  
	
		
		
		
	


	
	
	
		update user_t set name = #{_parameter} where id = 1
	

import java.util.Properties;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.github.pagehelper.PageHelper;

@Configuration
public class MyBatisConfiguration {

@Bean
public PageHelper pageHelper() {
PageHelper pageHepler = new PageHelper();
Properties p = new Properties();
p.setProperty("offsetAsPageNum", "true");
p.setProperty("rowBoundsWithCount", "true");
p.setProperty("reasonable", "true");
pageHepler.setProperties(p);
return pageHepler;
}
}

Mapper

@Mapper
public interface UserMapper {

	public List getAllUsers();
	
	public int updateUser(String name);
}



你可能感兴趣的:(springboot mybatis整合redis)