springboot 통합 my batis 및 패키지 curd 작업 - 프로필

23713 단어
1 프로필 application.properties  #server. port = 8090 server. address = 127.0.1 server. session. timeout = 1800 server. error. whitelabel. enabled = true \ # mybatis mybatis. config - locations = classpath: mybatis / mybatis - config. xml / mybatis 설정 파일 mybatis. mapper - locations = classpath: mybatis / mapper / *. xml / / mapper 맵 파일
 
mybatis-config.xml



"1.0" encoding="UTF-8" ?>
span style="color:#800000;">"-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">

      
        
        
      "cacheEnabled" value="true"/>  
        
        "callSettersOnNulls" value="true"/>  
     
    
    
        "Integer" type="java.lang.Integer" />
        "Long" type="java.lang.Long" />
        "HashMap" type="java.util.HashMap" />
        "LinkedHashMap" type="java.util.LinkedHashMap" />
        "ArrayList" type="java.util.ArrayList" />
        "LinkedList" type="java.util.LinkedList" />
    
    
    
    
BaseMapper.xml





    
    
    
        insert into ${table}
        
            close=")" separator=",">
            ${item1}
        
        values
        
            close=")" separator=",">
            #{item2}
        
    
    
    
        useGeneratedKeys="true" keyProperty="id">
        insert into ${table}
        
            close=")" separator=",">
            ${item}
        
        values
        
            close=")" separator=",">
            #{item}
        
    

    
    
        update ${table} set
        
            separator=",">
            ${item} = #{columnvalues[${item}]}
        
        
            <if test="wheres != null">
                1=1
                
                    
                        
                            
                                
                                   
                                    ${item}
                                
                                <when
                                    test='val.toString() == "=" || val.toString() == "!=" || val.toString() == "<" || val.toString() == ">" 
                                      || val.toString() == "<=" || val.toString() == ">=" || val.toString() == "like" 
                                      || val.toString() == "is null" || val.toString() == "is not null"'>
                                     
                                
                                
                                    #{val}
                                
                            
                        
                    
                
            if>
        
    

    
    
        delete from ${table}
        
            <if test="wheres != null">
                1=1
                
                    
                        
                            
                                
                                   
                                    ${item}
                                
                                <when
                                    test='val.toString() == "=" || val.toString() == "!=" || val.toString() == "<" || val.toString() == ">" 
                                      || val.toString() == "<=" || val.toString() == ">=" || val.toString() == "like" 
                                      || val.toString() == "is null" || val.toString() == "is not null"'>
                                     
                                
                                
                                    #{val}
                                
                            
                        
                    
                
            if>
        
    

    
    
        delete from ${table}
        
            <if test="wheres != null">
                ${idkey} in
                
                    close=")" separator=",">
                    #{item}
                
            if>
        
    
    
    

    
    

    
    

    
    

    
    

    
    
         
    
    
    
         
    

    
    
         
    

    
    

    
    

    
    
pom.xml




    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    4.0.0

    com.example
    smalldemo
    2
    war

    SpringBootDemo
    Demo project for Spring Boot

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

    
        UTF-8
        UTF-8
        1.7
    

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

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

        
            com.alibaba
            fastjson
            1.2.16
        
        
        
           com.alibaba
           druid-spring-boot-starter
           1.1.2
        
       
         
            mysql
            mysql-connector-java
            runtime
        
        
            org.springframework.boot
            spring-boot-starter-test
            test
        
        
          
           com.caucho  
            hessian  
            4.0.38
        
        
        
        
        
        
                org.springframework.boot
                spring-boot-starter-tomcat
                provided
        
        
        
        
            com.github.wxpay
            wxpay-sdk
            0.0.3
        
        
            org.apache.httpcomponents
            httpclient
            4.5.3
        


        
            net.sourceforge.htmlunit
            htmlunit
        
    


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


Application.java

/**
 *      
 * spring boot application          
 * @author sys
 *
 */
@SpringBootApplication
@EnableAutoConfiguration(exclude = { JacksonAutoConfiguration.class })
@ServletComponentScan
@EnableTransactionManagement //      
@MapperScan("com.sys.mapper")
public class Application  extends SpringBootServletInitializer{
        //fastkson
        @Bean
        public HttpMessageConverters fastJsonHttpMessageConverters() {
           FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
           FastJsonConfig fastJsonConfig = new FastJsonConfig();
           fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
           fastConverter.setFastJsonConfig(fastJsonConfig);
           HttpMessageConverter> converter = fastConverter;
           return new HttpMessageConverters(converter);
        }
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(Application.class);
        }
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
}

다음 편 계속 -- 자바 my batis 에 대한 curd 패키지 
원본 연락
다음으로 전송:https://www.cnblogs.com/syscn/p/7506711.html

좋은 웹페이지 즐겨찾기