myeclipse搭建spring boot+mybatis

本项目使用的环境:

  • 开发工具:myeclipse
  • springboot: 1.5.6
  • jdk:1.7
  • maven:3.3.9  

1.使用myeclipse创建一个maven项目。

myeclipse搭建spring boot+mybatis_第1张图片

myeclipse搭建spring boot+mybatis_第2张图片myeclipse搭建spring boot+mybatis_第3张图片

ps:选择jar java project,选择war 为 web project

点击finish结束。如图:

myeclipse搭建spring boot+mybatis_第4张图片

2.整合spring boot

myeclipse搭建spring boot+mybatis_第5张图片

将app放到com.guo下

package com.guo;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan("com.guo.dao")//将项目中对应的mapper类的路径加进来就可以了
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}

application.yml文件放置:src/main/resoures下

server:
  port: 8080

spring:
    datasource:
        name: test
        url: jdbc:mysql://127.0.0.1:3306/rce
        username: root
        password: wangyun123
        # 使用druid数据源
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name: com.mysql.jdbc.Driver
        filters: stat
        maxActive: 20
        initialSize: 1
        maxWait: 60000
        minIdle: 1
        timeBetweenEvictionRunsMillis: 60000
        minEvictableIdleTimeMillis: 300000
        validationQuery: select 'x'
        testWhileIdle: true
        testOnBorrow: false
        testOnReturn: false
        poolPreparedStatements: true
        maxOpenPreparedStatements: 20
mybatis:
  mapper-locations: classpath:mapper/*.xml
  type-aliases-package: com.guo.vo

#pagehelper分页插件
pagehelper:
    helperDialect: mysql
    reasonable: true
    supportMethodsArguments: true
    params: count=countSql

映射文件:userMapper.xml放置:src/main/resoures/mapper下:


  4.0.0
  com.guo
  demo-parent
	pom
	0.0.1-SNAPSHOT
	
	
		org.springframework.boot
		spring-boot-starter-parent
		1.5.6.RELEASE
	
	
	
		UTF-8
		UTF-8
	
		1.8
	
	
	
		
			org.springframework.boot
			spring-boot-starter-web
		
		
		
			org.springframework.boot
			spring-boot-devtools
			true
		
		
		
			org.springframework.boot
			spring-boot-starter-test
			test
		
		
		
			org.springframework.boot
			spring-boot-starter-jdbc
		
		
		
			org.mybatis.spring.boot
			mybatis-spring-boot-starter
			1.3.1
		
		
		
			mysql
			mysql-connector-java
			5.1.42
		
		
		
			org.mybatis.generator
			mybatis-generator-core
			1.3.5
		
		
		
			com.alibaba
			fastjson
			1.2.23
		
		
			xml-apis
			xml-apis
			2.0.2
		
		
			commons-net
			commons-net
			3.5
		
		
			net.sf.json-lib
			json-lib
			2.4
			jdk15
		
		
		
			com.github.pagehelper
			pagehelper-spring-boot-starter
			1.1.2
		
		
		
			com.alibaba
			druid-spring-boot-starter
			1.1.0
		
	
	
		
			
				maven-compiler-plugin
				
					1.8
					1.8
				
			
			
			
				org.springframework.boot
				spring-boot-maven-plugin
			
		
	

https://download.csdn.net/download/gc1329689056/10547131  源码

你可能感兴趣的:(spring,boot)