SSM(spring springmvc mybatis IDEA编程 多模块其实和多层类似)

最近在学习java,熟悉java编程和一些框架(特殊原因,真香!!),这里推荐大家一个网址(只求速成,直接上手的,直接点这个网址,自己照着看,照着打就行了)https://www.bilibili.com/video/av49737702/?p=13

我这里给大家分享一些好东西,至于SSM框架原理自己找东西看吧

一.当遇到下载依赖的时候突然发现“Generating project in Batch mode”这个问题时,不用担心,这是因为下载的Generating project in Batch mode文件有点大,(毕竟链接的国外网址)解决方法如下:

1.直接通过链接http://repo.maven.apache.org/maven2/archetype-catalog.xml下载或者通过文件夹链接http://repo.maven.apache.org/maven2/然后找到archetype-catalog.xml右键保存进行下载(推荐!)。该文件共4.1M。

2.然后将这个下载好的文件复制到C:\Users\(当前登录的人)\.m2\repository\org\apache\maven\archetype\archetype-catalog\3.1.1(我这里的是3.1.1,你们自己的看情况)下

3.然后在执行的命令后面加上增加参数-DarchetypeCatalog=local,变成读取本地文件即可。(IDEA点击file-搜索maven-Runner-选择run in background,在vm options这里填写-DarchetypeCatalog=local

二:manager层依赖要写好多,这里也给大家吧(这里的version是填写使用版本,而我都写在了父工程中)

pom.xml:




    
        comm-parent
        com.zhang
        1.0-SNAPSHOT
    
    4.0.0

    manager
    war

    manager Maven Webapp
    
    http://www.example.com

    
        UTF-8
        1.7
        1.7
    

    
    
        
        
        
            org.springframework
            spring-aop
            ${spring.version}
        
        
        
            org.springframework
            spring-aspects
            ${spring.version}
        
        
        
            org.springframework
            spring-beans
            ${spring.version}
        
        
        
            org.springframework
            spring-context
            ${spring.version}
        
        
        
            org.springframework
            spring-core
            ${spring.version}
        
        
        
            org.springframework
            spring-expression
            ${spring.version}
        
        
        
            org.springframework
            spring-jdbc
            ${spring.version}
        
        
        
            org.springframework
            spring-orm
            ${spring.version}
        
        
        
            org.springframework
            spring-oxm
            ${spring.version}
        
        
        
            org.springframework
            spring-tx
            ${spring.version}
        
        
        
            org.springframework
            spring-test
            ${spring.version}
        
        
        
            org.springframework
            spring-web
            ${spring.version}
        
        
        
            org.springframework
            spring-webmvc
            ${spring.version}
        

        
        
            org.mybatis
            mybatis-spring
            ${mybatis-spring.version}
        

        
        
            service
            com.zhang
            1.0-SNAPSHOT
        

        
        
            mysql
            mysql-connector-java
            ${mysql.version}
        
        
        
            com.mchange
            c3p0
            ${c3p0.version}
        

        
        
            jstl
            jstl
            ${jstl.version}
        
        
            taglibs
            standard
            ${taglibs.version}
        

        
        
            log4j
            log4j
            ${log4j.version}
        
        
            org.slf4j
            slf4j-api
            ${slf4j.version}
        
        
            org.slf4j
            slf4j-log4j12
            ${slf4j.version}
        
        
        
            javax.servlet
            javax.servlet-api
            3.1.0
            provided
        
        
            javax.servlet.jsp
            javax.servlet.jsp-api
            2.3.1
            provided
        
    

    
        manager
        
            
                
                    maven-clean-plugin
                    3.1.0
                
                
                
                    maven-resources-plugin
                    3.0.2
                
                
                    maven-compiler-plugin
                    3.8.0
                
                
                    maven-surefire-plugin
                    2.22.1
                
                
                    maven-war-plugin
                    3.2.2
                
                
                    maven-install-plugin
                    2.5.2
                
                
                    maven-deploy-plugin
                    2.8.2
                
            
        
    

三.这里提供一些xml文件给大家吧(主要是manager层要写好多东西)我这边使用的applicationContext.xml可以舍去mybatis.xml

web.xml:




    
    
        DispatcherServlet
        org.springframework.web.servlet.DispatcherServlet
        
            contextConfigLocation
            classpath:springmvc.xml
        
        1
    

    
        DispatcherServlet
        /
    

    
    
        contextConfigLocation
        classpath:applicationContext.xml
    
    
        org.springframework.web.context.ContextLoaderListener
    

db.properties:

#加载驱动
jdbc.driver=com.mysql.jdbc.Driver
#加载数据库
jdbc.url=jdbc:mysql://localhost:3306/test
#用户名
jdbc.user=root
#密码
jdbc.password=123456

log4j.properties:

### 设置###
log4j.rootLogger = debug,stdout 
### 输出信息到控制抬 ###
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n

mybatis.xml:




    
    
        
        
    

    
    
        
    

springmvc.xml:




    
    

    
    

    
    

    
    
        
        
        
        
    

applicationContext.xml:




    

    
    
        
        
        
        
        
        
    

    
    
        
        
        
        
        
    

    
    
        
        
    

    
    

    
    
    
        
    
    
    
        
            
            
            
            
        
    
    
        
        
        
        
    

你可能感兴趣的:(SSM框架学习,IDEA编程)