springboot+mybatis+generator配置项目跑起来的样例

springboot+mybatis+generator配置项目跑起来的样例_第1张图片

pom.xml



	4.0.0
	
		org.springframework.boot
		spring-boot-starter-parent
		2.7.6
		 
	
	com.mall.internet
	order
	0.0.1-SNAPSHOT
	order
	模拟外卖订单
	
		11
	
	
		
			org.springframework.boot
			spring-boot-starter-web
		
		
			org.mybatis.spring.boot
			mybatis-spring-boot-starter
			1.3.2
		
		





		
		
		
			com.alibaba
			druid-spring-boot-starter
			1.1.1
		
		
			org.springframework.boot
			spring-boot-starter-test
			test
		
	

	
		
			
				org.springframework.boot
				spring-boot-maven-plugin
			
			
			
				org.mybatis.generator
				mybatis-generator-maven-plugin
				1.4.0
				
					${basedir}/src/main/resources/mybatis/generatorConfig.xml
					true
					true
				
				
				
					
						mysql
						mysql-connector-java
						8.0.21
					
					
						org.mybatis.generator
						mybatis-generator-core
						1.4.0
					
				
			
		
	


mybatis-config.xml




    
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    



    
    
    

generatorConfig.xml





    

        
            
            
            
        

        
        
        

        
        
            
            
        

        
        
            
            
        

        
        
            
        

        
        
            
        

        






        
            
            
        

application.yml

# 设置端口
server:
  port: 8080

# 设置数据源
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: wer%123
    # 连接池类型
    type: com.alibaba.druid.pool.DruidDataSource
    # 驱动
    driver-class-name: com.mysql.cj.jdbc.Driver
    # 连接池配置
    druid:
      # 最小数
      min-idle: 5
      # 最大数
      max-active: 20
      # 初始大小
      initial-size: 5
      # 配置获取连接等待超时时间
      max-wait: 6000
      # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
      time-between-eviction-runs-millis: 60000
      # 配置一个连接在池中最小生存时间  单位为毫秒
      min-evictable-idle-time-millis: 300000
      validation-query: SELECT 1 FROM DUAL
      test-while-idle: true
      test-on-borrow: false
      test-on-return: false
      # 打开 PSCache,并且指定每个连接上PSCache的大小
      pool-prepared-statements: true
      max-pool-prepared-statement-per-connection-size: 20
      # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,wall用于防火墙
      filters: stat,wall

# 配置mybatis
mybatis:
  mapper-locations: classpath:mybatis/mappers/*.xml
  # 全局的映射,不用在xml文件写实体类的全路径
  type-aliases-package: com.mall.internet.order.dal.entity
  configuration:
    # 开启驼峰映射
    map-underscore-to-camel-case: true

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