4.0.0
com.springmvc
hellobeijing
1.0-SNAPSHOT
war
hellobeijing Maven Webapp
http://maven.apache.org
4.2.5.RELEASE
3.2.4
1.6.6
1.2.12
org.springframework
spring-core
${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-test
${spring.version}
org.mybatis
mybatis
${mybatis.version}
org.mybatis
mybatis-spring
1.2.2
mysql
mysql-connector-java
5.1.29
com.mchange
c3p0
0.9.5.2
junit
junit
4.11
test
javax.servlet
jstl
1.2
javax.servlet.jsp
jsp-api
2.2.1-b03
provided
javax.servlet
servlet-api
2.5
provided
com.fasterxml.jackson.core
jackson-core
2.7.1
com.fasterxml.jackson.core
jackson-annotations
2.7.1
com.fasterxml.jackson.core
jackson-databind
2.7.1
net.sf.json-lib
json-lib
2.4
jdk15
commons-lang
commons-lang
2.4
commons-logging
commons-logging
1.1
commons-pool
commons-pool
1.5.6
commons-dbcp
commons-dbcp
1.4
commons-beanutils
commons-beanutils
1.8.3
commons-httpclient
commons-httpclient
3.1
commons-collections
commons-collections
3.1
commons-codec
commons-codec
1.9
javax.annotation
jsr250-api
1.0
net.sf.ezmorph
ezmorph
1.0.6
javax.activation
activation
1.1
taglibs
standard
1.1.2
log4j
log4j
${log4j.version}
org.slf4j
slf4j-api
${slf4j.version}
org.slf4j
slf4j-log4j12
${slf4j.version}
commons-fileupload
commons-fileupload
1.3.1
commons-io
commons-io
2.4
helloworld
org.mybatis.generator
mybatis-generator-maven-plugin
1.3.2
true
true
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8
jdbc.username=root
jdbc.password=MuLin_20190822
#最大连接数
maxPoolSize=20
#最小连接数
minPoolSize=10
#连接超时时间
checkoutTimeout=60000
#失败重连次数
acquireRetryAttempts=3
Archetype Created Web Application
contextConfigLocation
classpath:spring/applicationContext.xml
encodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
UTF-8
encodingFilter
/*
org.springframework.web.context.ContextLoaderListener
SpringMVC
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:dispatcherServlet.xml
1
SpringMVC
/
1.6.6
1.2.12
log4j
log4j
${log4j.version}
org.slf4j
slf4j-api
${slf4j.version}
org.slf4j
slf4j-log4j12
${slf4j.version}
### set log levels ###
log4j.rootLogger = INFO,D
###输出到控制台###
log4j.logger.toConsole=debug,stdout
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
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} [%5p] - %c -%F(%L) -%m%n
### 输出到日志文件 ###
## 其中File 可以采用绝对路径 亦可以采用相对路径 catalina.home 是tomcat目录 如果没有logs文件夹 将会报错 ##
## 更加倾向于将日志文件放在 D:/database/log4j/log4jTest/logtest.log ##
## 绝对路径如:e:/logtest.log ##
log4j.logger.daily=INFO,D
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = D:/database/log4j/log4jTest/logtest.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = INFO
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern =%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %c -%F(%L) -%m%n
##log4j.logger.org.apache.ibatis=debug,stdout
##log4j.logger.java.sql=debug,stdout
注意:mybatis-generator-maven-plugin 插件的plugins标签要与pluginManagement标签并列,不然在右边Maven中找不到该插件
org.mybatis.generator
mybatis-generator-core
1.3.5
org.mybatis.generator
mybatis-generator-maven-plugin
1.3.5
true
true
package com.springmvc.service;
import com.springmvc.dao.UserMapper;
import com.springmvc.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@Transactional
public class UserService {
@Autowired
UserMapper userMapper;
public User getUserById(Integer id){
return userMapper.selectByPrimaryKey(id);
}
}
package com.springmvc.controller;
import com.springmvc.entity.User;
import com.springmvc.service.UserService;
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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value="/getUser",method = RequestMethod.GET)
@ResponseBody
public User getUser(Integer id){
User user = userService.getUserById(id);
return user;
}
}
找到该页面,将 Autowiring for Bean Class √去掉,Apply OK