java免费ssm项目,一个简单的Java SSM项目,记录

写在前面的扑街(gai)日记:我连初心都快忘了,竟然还能想起她,这该死的。。。该死的bug!!!

环境:windows 7

开发工具:IDEA 2020

数据库:mysql 8.0

项目实现预览:

27a78d7c4c4f5675f66d22d12d931bc3.png

mysql8.0表单预览:

5d9edd42489855749c84723b32513e1a.png

简单ssm项目开始:

ssm项目:spring springmvc mybatis

1,导入依赖 :

pom.xml  :

org.springframework

spring-jdbc

4.3.11.RELEASE

org.springframework

spring-webmvc

4.3.11.RELEASE

org.mybatis

mybatis

3.4.5

org.mybatis

mybatis-spring

1.3.1

mysql

mysql-connector-java

8.0.11

com.mchange

c3p0

0.9.5.1

javax.servlet

javax.servlet-api

4.0.0

provided

(放入build里面)

src/main/java

**/*.xml

项目结构预览):

769a984b309d8009721f5884ba6748df.png

2,建立springMvc.xml 配置文件

springMvc.xml:

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:context="http://www.springframework.org/schema/context"

xmlns:mvc="http://www.springframework.org/schema/mvc"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd

http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd

">

3,配置web.xml:

/p>

"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/dtd/web-app_2_3.dtd" >

Archetype Created Web Application

contextConfigLocation

classpath:applicationContext.xml

org.springframework.web.context.ContextLoaderListener

SpringMvc

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath:springMvc.xml

SpringMvc

*.action

4,建立 db.properties 和配置 application.xml 以及 mybatis-config.xml和配置

db.properties:

uname=root

upass=1234

url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT

driver_Class=com.mysql.cj.jdbc.Driver

initPoolSize=5

maxPoolSize=20

applicationContext.xml:

xmlns:context="http://www.springframework.org/schema/context"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

mybatis-config.xml:

/p>

PUBLIC "-//mybatis.org//DTD Config 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-config.dtd">

java文件夹里面:

controllers 里面StudentController:

package controllers;

import com.alibaba.fastjson.JSON;

import dao.StudentDao;

import entity.Student;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

import java.util.List;

/**

* SSM+UI CRUD

*/

@Controller

public class StudentController {

HttpServletResponse response;

@Autowired

private StudentDao studentDao;

// 查询所有

@ResponseBody

@RequestMapping("getStudent")

public List getStudent(){

System.out.println("查询所有111");

List list=studentDao.getStudent();

System.out.println("哈哈");

String data = JSON.toJSONString(list);

return list;

}

@ResponseBody

@RequestMapping("test")

public String test(){

System.out.println("进来了");

return "ok";

}

}

dao 里面StudentDao:

package dao;

import entity.Student;

import java.util.List;

public interface StudentDao {

public List getStudent();

}

entity 里面Student:

package entity;

public class Student {

private int id ;

private String name ;

private int age ;

public Student() {

}

public Student(int id, String name, int age) {

this.id = id;

this.name = name;

this.age = age;

}

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

}

mappingXml 里面 Student.xml:

/p>

PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"

"http://mybatis.org/dtd/mybatis-3-mapper.dtd"

>

id , name , age

select * from student

en,差不多就这样了,扑街(gai)一天,结束。。。

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值