package com.sharding;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication
@ImportResource( "classpath*:sharding-jdbc.xml" )
@MapperScan( "com.sharding.mapper" )
public class ShardingTest {
public static void main(String[] args) {
SpringApplication.run(ShardingTest. class );
}
}
package com.sharding.test;
import com.sharding.mapper.OrderMapper;
import com.sharding.pojo.vo.Order;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
@RunWith(SpringRunner. class )
@SpringBootTest
public class AppTest {
@Autowired
private OrderMapper orderMapper;
@Test
public void testInsert(){
Order order = new Order();
order.setId( 10 );
order.setUserId( 20 );
order.setAmount( 200 );
order.setName( "Test" );
orderMapper.insert(order);
}
@Test
public void testQuery(){
List <Order> test = orderMapper.getOrderByName("Test" );
System.out.println( "查询结果:" + test);
}
}
spring整合sharding-jdbc实现分库分表
标签:use sharp space his mybatis HERE tin engine ati
查看更多关于spring整合sharding-jdbc实现分库分表的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did118401