Spring5x-base

Spring5x-base_第1张图片
spring5x-base-目录.png

此模块是基础模块,其它模块都是以此模块扩展

Spring5x-base:是一个非常干净的spring5.x+springMVC架构

Spring5x-base的作用:

  • 可以直接拷贝这个模块,改名成其它模块名称

推荐-接口调试:

  • 浏览器调用调试接口
  • Postman 工具调用接口调试(极力建议)
  • swagger Api 调试接口(推荐)

Spring5x-base 搭建过程:

功能:

  • 单纯的 spring+springmvc 框架
  • 版本spring 5.x

项目结构:特别简单的基础框架,往后的spring xml配置方式都是以此框架的为基础。


Spring5x-base_第2张图片
base_1.png

1、pom.xml 引入依赖




    4.0.0
    
    com.zja
    spring5x-base
    war

    spring5x-base

    
    
        
        5.0.9.RELEASE
        
        1.8
        
        UTF-8
        3.6.0
        2.19.1
        2.6
        4.0.1
    

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

        
        
            javax.servlet
            javax.servlet-api
            ${servlet.version}
            provided
        
    

    
        spring5x-base
        
            
            
                maven-compiler-plugin
                ${maven.compiler.plugin.version}
                
                    
                    ${jdk.version}
                    
                    ${jdk.version}
                    
                    ${project.build.sourceEncoding}
                
            
            
            
                maven-surefire-plugin
                ${mavne.surefire.plugin.version}
                
                    true
                
            
        
    


2、spring-mvc.xml 配置




    
    

    
    

    
    
        
        
        
            
        
        
    

    
    

    
    
        
        
        
        
    


3、web.xml 配置




    
    
        springMvc
        org.springframework.web.servlet.DispatcherServlet
        
            contextConfigLocation
            classpath:META-INF/spring/spring-mvc.xml
        
        1
    

    
        springMvc
        /
    



4、HelloController 接口测试

package com.zja.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author ZhengJa
 * @description HelloController
 * @data 2019/10/24
 */
@Controller
public class HelloController {

    @GetMapping("/hello")
    public String hello(){
        //返回hello页面
       return  "hello";
    }

    @GetMapping("/hello2")
    @ResponseBody
    public String hello2(){
        //返回字符串
        return  "hello2 字符串";
    }
}

5、测试-页面访问

  • 访问:http://localhost:8080/spring5x-base/hello
  • 效果:hello.jsp 页面 或 hello.html 页面

数据访问

  • 访问:http://localhost:8080/spring5x-base/hello2
  • 效果:hello2 字符串

基础搭建已经可以结束!!!

github 地址:

  • https://github.com/zhengjiaao/spring5x

博客地址

  • :https://www.jianshu.com/u/70d69269bd09
  • 掘金: https://juejin.im/user/5d82daeef265da03ad14881b/posts

你可能感兴趣的:(Spring5x-base)