《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》,点击传送门,即可获取!
数据库的密码
password=admin
定义初始连接数
initialSize=1
定义最大连接数
maxActive=20
定义最大空闲
maxIdle=20
定义最小空闲
minIdle=1
定义最长等待时间
maxWait=60000
4.log4j.properties
#日志输出级别
log4j.rootLogger=debug,stdout,D,E
#设置stdout的日志输出控制台
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#输出日志到控制台的方式,默认为System.out
log4j.appender.stdout.Target = System.out
#设置使用灵活布局
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#灵活定义输出格式
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} -[%p] method:[%c (%rms)] - %m%n
5.spring-mvc.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns=“http://www.springframework.org/schema/beans”
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-3.0.xsd">
<context:component-scan base-package=“com.sjsq”/>
mvc:annotation-driven/
mvc:default-servlet-handler/
6.web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xmlns=“http://java.sun.com/xml/ns/javaee”
xmlns:web=“http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd”
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version=“2.5”>
Archetype Created Web Application
contextConfigLocation
classpath:applicationContext.xml
org.springframework.web.context.ContextLoaderListener
springmvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring-mvc.xml
1
springmvc
*.do
index.jsp
list.jsp
要放在web/WEB-INF/views下面。
<%@ page language=“java” import=“java.util.*” pageEncoding=“UTF-8”%>
<%@ taglib prefix=“c” uri=“http://java.sun.com/jsp/jstl/core”%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+“😕/”+request.getServerName()+“:”+request.getServerPort()+path+“/”;
%>
<c:forEach items=“${list}” var=“bean”>
${bean.id} ${bean.username} ${bean.password}</c:forEach>
User
package com.sjsq.model;
/**
-
实体类
-
@author shuijianshiqing
-
@date 2020/6/21 10:21
*/
public class User {
private Integer id;
private String username;
private String password;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return “User{” +
“id=” + id +
“, username='” + username + ‘’’ +
“, password='” + password + ‘’’ +
‘}’;
}
}
UserDao
package com.sjsq.dao;
import com.sjsq.model.User;
import java.util.List;
/**
-
@author shuijianshiqing
-
@date 2020/6/21 10:29
*/
public interface UserDao {
/**
-
获取所有用户信息
-
@return
*/
public List list();
}
UserDaoImpl
package com.sjsq.dao.impl;
import com.sjsq.dao.UserDao;
import com.sjsq.model.User;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
-
@author shuijianshiqing
-
@date 2020/6/21 10:30
*/
@Repository(“userDao”)
public class UserDaoImpl extends SqlSessionDaoSupport implements UserDao {
@Autowired
@Override
public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
super.setSqlSessionFactory(sqlSessionFactory);
}
/**
-
返回查询结果
-
@return
*/
public List list() {
return this.getSqlSession().selectList(“com.sjsq.model.user.mapper.list”);
}
}
UserService
package com.sjsq.service;
import com.sjsq.model.User;
import java.util.List;
/**
-
@author shuijianshiqing
-
@date 2020/6/21 10:38
*/
public interface UserService {
public List list();
}
UserServiceImpl
package com.sjsq.service.impl;
import com.sjsq.dao.UserDao;
import com.sjsq.model.User;
import com.sjsq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
-
@author shuijianshiqing
-
@date 2020/6/21 10:38
*/
@Service(“userService”)
public class UserServiceImpl implements UserService {
@Autowired
private UserDao userDao;
public void setUserDao(UserDao userDao){
this.userDao = userDao;
}
public List list() {
return userDao.list();
}
}
UserController
package com.sjsq.controller;
import com.sjsq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
/**
-
@author shuijianshiqing
-
@date 2020/6/21 10:42
*/
@Controller
public class UserController {
@Autowired
private UserService userService;
// Spring使用set方法进行依赖注入
public void setUserService(UserService userService) {
this.userService = userService;
}
/**
-
查询所有用户信息
-
@param map
-
@return
*/
@RequestMapping(“/list”)
public String list(ModelMap map){
map.addAttribute(“list”, userService.list());
return “list”;
}
}
======================================================================
drop database if exists maven-ssm-demo;
create database maven-ssm-demo;
drop table if exists user
;
create table user
(
id
int(11) not null auto_increment,
username
varchar(255) default null,
password
varchar(255) default null,
primary key (id
)
);
insert into user
values (1, ‘sjsq’, ‘123456’);
=====================================================================
浏览器输入:http://localhost:8080/list.do,就可以访问到页面了。
======================================================================
使用Jar包的方式搭建SSM,避免了配置Maven的麻烦。感觉效率越来越高了,这次只用了一早上就把环境搭建好了。
最后
Java架构进阶面试及知识点文档笔记
这份文档共498页,其中包括Java集合,并发编程,JVM,Dubbo,Redis,Spring全家桶,MySQL,Kafka等面试解析及知识点整理
Java分布式高级面试问题解析文档
其中都是包括分布式的面试问题解析,内容有分布式消息队列,Redis缓存,分库分表,微服务架构,分布式高可用,读写分离等等!
互联网Java程序员面试必备问题解析及文档学习笔记
Java架构进阶视频解析合集
《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》,点击传送门,即可获取!
览器输入:http://localhost:8080/list.do,就可以访问到页面了。
======================================================================
使用Jar包的方式搭建SSM,避免了配置Maven的麻烦。感觉效率越来越高了,这次只用了一早上就把环境搭建好了。
最后
Java架构进阶面试及知识点文档笔记
这份文档共498页,其中包括Java集合,并发编程,JVM,Dubbo,Redis,Spring全家桶,MySQL,Kafka等面试解析及知识点整理
[外链图片转存中…(img-ZSILpkZa-1714665503488)]
Java分布式高级面试问题解析文档
其中都是包括分布式的面试问题解析,内容有分布式消息队列,Redis缓存,分库分表,微服务架构,分布式高可用,读写分离等等!
[外链图片转存中…(img-YvdAG1GW-1714665503489)]
互联网Java程序员面试必备问题解析及文档学习笔记
[外链图片转存中…(img-DZLTGZel-1714665503489)]
Java架构进阶视频解析合集
《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》,点击传送门,即可获取!