调整项目,解决编译报错问题

This commit is contained in:
Zhang Peng 2019-11-28 21:36:35 +08:00
parent 8bca69d008
commit 841a56c346
428 changed files with 1203 additions and 1166 deletions

View File

@ -154,7 +154,7 @@ ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath*:conf/app
## 示例代码
我的示例代码地址:[spring-examples-core-resouces](https://github.com/dunwu/spring-tutorial/tree/master/spring-examples/spring-examples-core/spring-examples-core-resouces)
我的示例代码地址:[spring-tutorial-core-resouces](https://github.com/dunwu/spring-tutorial/tree/master/spring-tutorial/spring-tutorial-core/spring-tutorial-core-resouces)
## 参考资料

View File

@ -1,271 +1,265 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Spring Tutorial</title>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
<meta content="Spring Tutorial" name="description" />
<meta
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
name="viewport"
/>
<link href="http://dunwu.test.upcdn.net/common/logo/zp_50_50.png" rel="icon" type="image/x-icon" />
<link href="//unpkg.com/docsify/lib/themes/vue.css" rel="stylesheet" title="vue" />
<style>
h1 + ul {
display: block !important;
<head>
<meta charset="UTF-8" />
<title>Spring Tutorial</title>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible" />
<meta content="Spring Tutorial" name="description" />
<meta
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
name="viewport"
/>
<link href="http://dunwu.test.upcdn.net/common/logo/zp_50_50.png" rel="icon" type="image/x-icon" />
<link href="//unpkg.com/docsify/lib/themes/vue.css" rel="stylesheet" title="vue" />
<style>
h1 + ul {
display: block !important;
}
.content img,
.sidebar img {
border: none;
border-radius: 4px;
box-shadow: 2px 2px 5px grey;
}
body,
.content,
.sidebar,
.sidebar-toggle,
.search input {
color: #6b615f !important;
background-color: #fff4e6 !important;
}
body strong,
.content strong,
.sidebar strong {
color: #5c5869 !important;
}
</style>
<style>
.cover-main .anchor span {
text-align: center;
background-image: -webkit-linear-gradient(left, #ffdcb4, #b96972 25%, #e88a57 50%, #804170 75%, #a596cd);
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
-webkit-background-size: 200% 100%;
-webkit-animation: masked-animation 1.5s infinite linear;
font-family: 'Brush Script MT', 隶书, serif;
font-weight: 600;
}
.cover-main blockquote p {
color: #5c5869;
font-family: 'Arial', 隶书, serif;
}
.cover-main ul a:hover {
color: #fe4165 !important;
}
.cover-main a:hover {
text-align: center;
background-image: -webkit-linear-gradient(left, #ffdcb4, #b96972 25%, #e88a57 50%, #804170 75%, #a596cd);
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
-webkit-background-size: 200% 100%;
-webkit-animation: masked-animation 1.5s infinite linear;
}
/* content 样式内容 */
.sidebar a,
.content a {
color: #399ab2 !important;
text-decoration: none !important;
}
.sidebar a:hover,
.content a:hover {
color: #fe4165 !important;
text-decoration: underline !important;
}
.content h1 :hover,
.content h2 :hover,
.content h3 :hover,
.content h4 :hover {
text-align: center;
background-image: -webkit-linear-gradient(left, #ffdcb4, #b96972 25%, #e88a57 50%, #804170 75%, #a596cd);
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
-webkit-background-size: 200% 100%;
-webkit-animation: masked-animation 1.5s infinite linear;
font-family: '微软雅黑', serif;
font-weight: bold;
}
@-webkit-keyframes masked-animation {
0% {
background-position: 0 0;
}
100% {
background-position: -100% 0;
}
}
.content h1 a,
.content h1 span {
color: #399ab2 !important;
font-size: 30px;
text-shadow: 2px 2px 5px grey;
}
.content h2 a,
.content h2 span {
color: #60497c !important;
font-size: 26px;
text-shadow: 2px 2px 5px grey;
}
.content h3 a,
.content h3 span {
color: #346093 !important;
font-size: 22px;
text-shadow: 2px 2px 5px grey;
}
.content h4 a,
.content h4 span {
font-size: 18px;
color: #78943a;
text-shadow: 2px 2px 5px grey;
}
</style>
<style>
.markdown-section h1 {
font-size: 1rem;
margin: 0;
}
.markdown-section h2 {
font-size: 1rem;
margin: 1rem 0px;
}
.markdown-section h3 {
font-size: 1rem;
margin: 0;
}
.markdown-section p {
line-height: 1rem;
word-spacing: 0.05rem;
}
</style>
<style>
.content > p {
font-size: 16px !important;
line-height: 24px;
}
.content blockquote {
display: block;
padding: 0 16px;
border-left: 8px solid #dddfe4;
background: #fff2c9;
overflow: auto;
}
.content pre {
padding-left: 0 !important;
padding-right: 0 !important;
border-radius: 8px;
box-shadow: 1px 1px 20px 3px #dddddd !important;
}
.content code {
background-color: white;
box-shadow: 1px 1px 1px lightgrey;
}
.content table {
display: table;
padding-left: 0 !important;
padding-right: 0 !important;
box-shadow: 2px 2px 20px 6px lightgrey !important;
}
.content th {
font-weight: bold;
font-size: 16px;
background-color: #cce6b6;
}
</style>
<style>
@media (min-width: 600px) {
.markdown-section pre > code {
font-size: 0.9rem !important;
}
}
@media (max-width: 600px) {
.markdown-section pre > code {
padding-top: 5px;
padding-bottom: 5px;
}
.content img,
.sidebar img {
border: none;
border-radius: 4px;
box-shadow: 2px 2px 5px grey;
pre:after {
content: '' !important;
}
}
body,
.content,
.sidebar,
.sidebar-toggle,
.search input {
color: #6b615f !important;
background-color: #fff4e6 !important;
@media (min-width: 600px) {
pre code {
padding-left: 20px !important;
}
}
body strong,
.content strong,
.sidebar strong {
color: #5c5869 !important;
}
</style>
<style>
.cover-main .anchor span {
text-align: center;
background-image: -webkit-linear-gradient(left, #ffdcb4, #b96972 25%, #e88a57 50%, #804170 75%, #a596cd);
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
-webkit-background-size: 200% 100%;
-webkit-animation: masked-animation 1.5s infinite linear;
font-family: 'Brush Script MT', 隶书, serif;
font-weight: 600;
}
.cover-main blockquote p {
color: #5c5869;
font-family: 'Arial', 隶书, serif;
}
.cover-main ul a:hover {
color: #fe4165 !important;
}
.cover-main a:hover {
text-align: center;
background-image: -webkit-linear-gradient(left, #ffdcb4, #b96972 25%, #e88a57 50%, #804170 75%, #a596cd);
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
-webkit-background-size: 200% 100%;
-webkit-animation: masked-animation 1.5s infinite linear;
}
/* content 样式内容 */
.sidebar a,
.content a {
color: #399ab2 !important;
text-decoration: none !important;
}
.sidebar a:hover,
.content a:hover {
color: #fe4165 !important;
text-decoration: underline !important;
}
.content h1 :hover,
.content h2 :hover,
.content h3 :hover,
.content h4 :hover {
text-align: center;
background-image: -webkit-linear-gradient(left, #ffdcb4, #b96972 25%, #e88a57 50%, #804170 75%, #a596cd);
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
-webkit-background-size: 200% 100%;
-webkit-animation: masked-animation 1.5s infinite linear;
font-family: '微软雅黑', serif;
font-weight: bold;
}
@-webkit-keyframes masked-animation {
0% {
background-position: 0 0;
}
100% {
background-position: -100% 0;
}
}
.content h1 a,
.content h1 span {
color: #399ab2 !important;
font-size: 30px;
text-shadow: 2px 2px 5px grey;
}
.content h2 a,
.content h2 span {
color: #60497c !important;
font-size: 26px;
text-shadow: 2px 2px 5px grey;
}
.content h3 a,
.content h3 span {
color: #346093 !important;
font-size: 22px;
text-shadow: 2px 2px 5px grey;
}
.content h4 a,
.content h4 span {
font-size: 18px;
color: #78943a;
text-shadow: 2px 2px 5px grey;
}
</style>
<style>
.markdown-section h1 {
font-size: 1rem;
margin: 0;
}
.markdown-section h2 {
font-size: 1rem;
margin: 1rem 0px;
}
.markdown-section h3 {
font-size: 1rem;
margin: 0;
}
.markdown-section p {
line-height: 1rem;
word-spacing: 0.05rem;
}
</style>
<style>
.content > p {
font-size: 16px !important;
line-height: 24px;
}
.content blockquote {
display: block;
padding: 0 16px;
border-left: 8px solid #dddfe4;
background: #fff2c9;
overflow: auto;
}
.content pre {
@media (max-width: 600px) {
pre {
padding-left: 0 !important;
padding-right: 0 !important;
border-radius: 8px;
box-shadow: 1px 1px 20px 3px #dddddd !important;
}
}
</style>
</head>
<body>
<div id="app">正在加载...</div>
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
<script>
window.$docsify = {
name: 'spring-tutorial',
repo: 'https://github.com/dunwu/spring-tutorial',
logo: 'http://dunwu.test.upcdn.net/common/logo/zp_100_100.png',
auto2top: true,
coverpage: true,
loadSidebar: true,
maxLevel: 4,
subMaxLevel: 2,
formatUpdated: '{MM}/{DD} {HH}:{mm}',
search: {
maxAge: 86400000, paths: ['/'], placeholder: '🔍 搜索', noData: '😭 没有结果!', depth: 4
},
disqus: 'spring-tutorial',
plugins: [EditOnGithubPlugin.create('https://github.com/dunwu/spring-tutorial/tree/master/docs/', null, function (file) {
if (file.indexOf('en') === -1) {
return '📝 编辑文档'
} else {
return '📝 Edit Document'
}
})]
}
</script>
<script src="//unpkg.com/docsify/lib/plugins/disqus.min.js"></script>
<script src="//unpkg.com/docsify-edit-on-github/index.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
.content code {
background-color: white;
box-shadow: 1px 1px 1px lightgrey;
}
.content table {
display: table;
padding-left: 0 !important;
padding-right: 0 !important;
box-shadow: 2px 2px 20px 6px lightgrey !important;
}
.content th {
font-weight: bold;
font-size: 16px;
background-color: #cce6b6;
}
</style>
<style>
@media (min-width: 600px) {
.markdown-section pre > code {
font-size: 0.9rem !important;
}
}
@media (max-width: 600px) {
.markdown-section pre > code {
padding-top: 5px;
padding-bottom: 5px;
}
pre:after {
content: '' !important;
}
}
@media (min-width: 600px) {
pre code {
padding-left: 20px !important;
}
}
@media (max-width: 600px) {
pre {
padding-left: 0 !important;
padding-right: 0 !important;
}
}
</style>
</head>
<body>
<div id="app">正在加载...</div>
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
<script src="//unpkg.com/docsify-edit-on-github/index.js"></script>
<script>
window.$docsify = {
name: 'spring-tutorial',
repo: 'https://github.com/dunwu/spring-tutorial',
logo: 'http://dunwu.test.upcdn.net/common/logo/zp_100_100.png',
auto2top: true,
coverpage: true,
loadSidebar: true,
maxLevel: 4,
subMaxLevel: 2,
formatUpdated: '{MM}/{DD} {HH}:{mm}',
search: {
maxAge: 86400000,
paths: ['/'],
placeholder: '🔍 搜索',
noData: '😭 没有结果!',
depth: 4
},
disqus: 'spring-tutorial',
plugins: [
EditOnGithubPlugin.create('https://github.com/dunwu/spring-tutorial/tree/master/docs/', null, function(file) {
if (file.indexOf('en') === -1) {
return '📝 编辑文档'
} else {
return '📝 Edit Document'
}
})
]
}
</script>
<script src="//unpkg.com/docsify/lib/plugins/disqus.min.js"></script>
<!--代码高亮-->
<!--@see https://github.com/PrismJS/prism -->
<script src="//unpkg.com/prismjs/components/prism-basic.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-java.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
</body>
<!--代码高亮-->
<!--@see https://github.com/PrismJS/prism -->
<script src="//unpkg.com/prismjs/components/prism-basic.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-bash.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-java.min.js"></script>
<script src="//unpkg.com/prismjs/components/prism-markdown.min.js"></script>
</body>
</html>

View File

@ -218,7 +218,7 @@ ehcache.xml 中的配置内容完全符合 Ehcache 的官方配置标准。
## 示例代码
我的示例代码地址:[spring-examples-integration-cache](https://github.com/dunwu/spring-tutorial/tree/master/spring-examples/spring-examples-integration/spring-examples-integration-cache)
我的示例代码地址:[spring-tutorial-integration-cache](https://github.com/dunwu/spring-tutorial/tree/master/spring-tutorial/spring-tutorial-integration/spring-tutorial-integration-cache)
## 参考资料

42
pom.xml
View File

@ -8,36 +8,16 @@
<version>1.0.4</version>
<packaging>pom</packaging>
<modules>
<module>spring-examples</module>
</modules>
<name>${project.artifactId}</name>
<description>spring 学习笔记</description>
<url>https://github.com/dunwu/spring-tutorial</url>
<inceptionYear>2016-2019</inceptionYear>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<developers>
<developer>
<name>Zhang Peng</name>
<email>forbreak@163.com</email>
<timezone>+8</timezone>
</developer>
</developers>
<issueManagement>
<system>Github</system>
<url>https://github.com/dunwu/spring-tutorial/issues</url>
</issueManagement>
<scm>
<url>https://github.com/dunwu/spring-tutorial</url>
<connection>scm:git:git://github.com/dunwu/spring-tutorial.git</connection>
<developerConnection>scm:git:ssh://git@github.com:dunwu/spring-tutorial.git</developerConnection>
</scm>
<description>Spring Tutorial</description>
<modules>
<module>spring-tutorial-parent</module>
<module>spring-tutorial-common</module>
<module>spring-tutorial-core</module>
<module>spring-tutorial-data</module>
<module>spring-tutorial-web</module>
<module>spring-tutorial-integration</module>
<module>spring-tutorial-security</module>
</modules>
</project>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- 使用 aliyun maven 仓库加速下载 -->

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.github.dunwu.spring</groupId>
<artifactId>spring-tutorial</artifactId>
<version>1.0.4</version>
<relativePath>..</relativePath>
</parent>
<artifactId>spring-examples</artifactId>
<packaging>pom</packaging>
<description>Spring 样例工程</description>
<modules>
<module>spring-examples-parent</module>
<module>spring-examples-common</module>
<module>spring-examples-core</module>
<module>spring-examples-data</module>
<module>spring-examples-web</module>
<module>spring-examples-integration</module>
<module>spring-examples-security</module>
</modules>
</project>

View File

@ -1,4 +0,0 @@
jdbc.driver=org.h2.Driver
jdbc.url=jdbc:h2:file:~/.h2/quickstart;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1
jdbc.username=sa
jdbc.password=

View File

@ -1,4 +0,0 @@
jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/mydb
jdbc.username=root
jdbc.password=root

View File

@ -1,6 +0,0 @@
# Redis settings
redis.host=localhost
redis.port=6379
redis.pass=root
redis.maxIdle=300
redis.testOnBorrow=true

View File

@ -1,18 +0,0 @@
# data source
jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/mydb
jdbc.username=root
jdbc.password=root
#定义初始连接数
initialSize=0
#定义最大连接数
maxActive=20
#定义最大空闲
maxIdle=20
#定义最小空闲
minIdle=1
#定义最长等待时间
maxWait=60000
# mybatis plugin settings
mapper.plugin=tk.mybatis.mapper.generator.MapperPlugin
mapper.Mapper=tk.mybatis.mapper.common.Mapper

View File

@ -1,7 +0,0 @@
###set log levels###
log4j.rootLogger=info, 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{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n

View File

@ -1,7 +0,0 @@
###set log levels###
log4j.rootLogger=info, 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{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n

View File

@ -6,12 +6,12 @@
<parent>
<groupId>io.github.dunwu.spring</groupId>
<artifactId>spring-examples-parent</artifactId>
<artifactId>spring-tutorial-parent</artifactId>
<version>1.0.4</version>
<relativePath>../spring-examples-parent</relativePath>
<relativePath>../spring-tutorial-parent</relativePath>
</parent>
<artifactId>spring-examples-common</artifactId>
<artifactId>spring-tutorial-common</artifactId>
<packaging>jar</packaging>
<description>为了保持代码的整洁,尽量将其他示例项目中所需用到的非 Spring 依赖或工具类汇集于此</description>

View File

@ -6,20 +6,20 @@
<parent>
<groupId>io.github.dunwu.spring</groupId>
<artifactId>spring-examples-parent</artifactId>
<artifactId>spring-tutorial-parent</artifactId>
<version>1.0.4</version>
<relativePath>../spring-examples-parent</relativePath>
<relativePath>../spring-tutorial-parent</relativePath>
</parent>
<artifactId>spring-examples-core</artifactId>
<artifactId>spring-tutorial-core</artifactId>
<packaging>pom</packaging>
<description>IoC container, Events, Resources, i18n, Validation, Data Binding, Type Conversion, SpEL, AOP
</description>
<modules>
<module>spring-examples-core-aop</module>
<module>spring-examples-core-ioc</module>
<module>spring-examples-core-resouces</module>
<module>spring-examples-core-validation-convert</module>
<module>spring-tutorial-core-aop</module>
<module>spring-tutorial-core-ioc</module>
<module>spring-tutorial-core-resouces</module>
<module>spring-tutorial-core-validation-convert</module>
</modules>
</project>

View File

@ -6,12 +6,12 @@
<parent>
<groupId>io.github.dunwu.spring</groupId>
<artifactId>spring-examples-parent</artifactId>
<artifactId>spring-tutorial-parent</artifactId>
<version>1.0.4</version>
<relativePath>../../spring-examples-parent</relativePath>
<relativePath>../../spring-tutorial-parent</relativePath>
</parent>
<artifactId>spring-examples-core-aop</artifactId>
<artifactId>spring-tutorial-core-aop</artifactId>
<packaging>jar</packaging>
<dependencies>

View File

@ -1,5 +1,6 @@
package io.github.dunwu.spring.core.aop;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
@Component

View File

@ -6,12 +6,12 @@
<parent>
<groupId>io.github.dunwu.spring</groupId>
<artifactId>spring-examples-parent</artifactId>
<artifactId>spring-tutorial-parent</artifactId>
<version>1.0.4</version>
<relativePath>../../spring-examples-parent</relativePath>
<relativePath>../../spring-tutorial-parent</relativePath>
</parent>
<artifactId>spring-examples-core-ioc</artifactId>
<artifactId>spring-tutorial-core-ioc</artifactId>
<packaging>jar</packaging>
<dependencies>

View File

@ -1,10 +1,11 @@
package io.github.dunwu.spring.core.bean;
import java.beans.PropertyDescriptor;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
import java.beans.PropertyDescriptor;
public class MyInstantiationAwareBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter {
public MyInstantiationAwareBeanPostProcessor() {
@ -19,13 +20,6 @@ public class MyInstantiationAwareBeanPostProcessor extends InstantiationAwareBea
return null;
}
// 接口方法实例化Bean之后调用
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
System.out.println("[InstantiationAwareBeanPostProcessorAdapter] call postProcessAfterInitialization");
return bean;
}
// 接口方法设置某个属性时调用
@Override
public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean,
@ -34,4 +28,11 @@ public class MyInstantiationAwareBeanPostProcessor extends InstantiationAwareBea
return pvs;
}
// 接口方法实例化Bean之后调用
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
System.out.println("[InstantiationAwareBeanPostProcessorAdapter] call postProcessAfterInitialization");
return bean;
}
}

View File

@ -1,6 +1,7 @@
package io.github.dunwu.spring.core.bean;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;
/**
* 一个 JavaBean 示例
@ -21,33 +22,6 @@ public class Person implements BeanFactoryAware, BeanNameAware, InitializingBean
System.out.println("【构造器】调用Person的构造器实例化");
}
public String getName() {
return name;
}
public void setName(String name) {
System.out.println("【注入属性】注入属性name");
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
System.out.println("【注入属性】注入属性address");
this.address = address;
}
public int getPhone() {
return phone;
}
public void setPhone(int phone) {
System.out.println("【注入属性】注入属性phone");
this.phone = phone;
}
@Override
public String toString() {
return "Person [address=" + address + ", name=" + name + ", phone=" + phone + "]";
@ -79,6 +53,33 @@ public class Person implements BeanFactoryAware, BeanNameAware, InitializingBean
System.out.println("【DiposibleBean接口】调用DiposibleBean.destory()");
}
public String getName() {
return name;
}
public void setName(String name) {
System.out.println("【注入属性】注入属性name");
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
System.out.println("【注入属性】注入属性address");
this.address = address;
}
public int getPhone() {
return phone;
}
public void setPhone(int phone) {
System.out.println("【注入属性】注入属性phone");
this.phone = phone;
}
// 通过<bean>的init-method属性指定的初始化方法
public void myInit() {
System.out.println("【init-method】调用<bean>的init-method属性指定的初始化方法");

View File

@ -3,12 +3,13 @@ package io.github.dunwu.spring.core.ioc.annotation;
import io.github.dunwu.spring.core.ioc.sample.Apple;
import io.github.dunwu.spring.core.ioc.sample.Banana;
import io.github.dunwu.spring.core.ioc.sample.Orange;
import javax.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import javax.inject.Inject;
/**
* 展示 @Resource 注解的用法
*

View File

@ -1,12 +1,13 @@
package io.github.dunwu.spring.core.ioc.annotation;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
/**
* 展示 @PostConstruct和@PreDestroy 注解的用法
* <p>

View File

@ -2,12 +2,13 @@ package io.github.dunwu.spring.core.ioc.annotation;
import io.github.dunwu.spring.core.ioc.sample.AbstractFruit;
import io.github.dunwu.spring.core.ioc.sample.Orange;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import javax.annotation.Resource;
/**
* 展示 @Resource 注解的用法
* <p>

View File

@ -1,11 +1,12 @@
package io.github.dunwu.spring.core.ioc.annotation;
import io.github.dunwu.spring.core.ioc.annotation.instrument.Instrument;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class Musician implements Performer {

View File

@ -1,6 +1,7 @@
package io.github.dunwu.spring.core.ioc.annotation.inject;
import io.github.dunwu.spring.core.ioc.annotation.inject.instrument.Instrument;
import java.util.Collection;
import java.util.List;
import java.util.Map;

View File

@ -3,7 +3,7 @@
<!-- logback中一共有5种有效级别分别是TRACE、DEBUG、INFO、WARN、ERROR优先级依次从低到高 -->
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<property name="FILE_NAME" value="spring-examples-data" />
<property name="FILE_NAME" value="spring-tutorial-core" />
<property name="PATTERN"
value="%d{HH:mm:ss.SSS} [%boldYellow(%thread)] [%highlight(%-5level)] %boldGreen(%c{36}.%M) - %boldBlue(%m%n)" />

View File

@ -6,12 +6,12 @@
<parent>
<groupId>io.github.dunwu.spring</groupId>
<artifactId>spring-examples-parent</artifactId>
<artifactId>spring-tutorial-parent</artifactId>
<version>1.0.4</version>
<relativePath>../../spring-examples-parent</relativePath>
<relativePath>../../spring-tutorial-parent</relativePath>
</parent>
<artifactId>spring-examples-core-resouces</artifactId>
<artifactId>spring-tutorial-core-resouces</artifactId>
<packaging>jar</packaging>
<dependencies>

View File

@ -1,10 +1,11 @@
package io.github.dunwu.spring.core.resources;
import java.beans.PropertyDescriptor;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;
import java.beans.PropertyDescriptor;
public class MyInstantiationAwareBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter {
public MyInstantiationAwareBeanPostProcessor() {
@ -19,13 +20,6 @@ public class MyInstantiationAwareBeanPostProcessor extends InstantiationAwareBea
return null;
}
// 接口方法实例化Bean之后调用
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
System.out.println("[InstantiationAwareBeanPostProcessorAdapter] call postProcessAfterInitialization");
return bean;
}
// 接口方法设置某个属性时调用
@Override
public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean,
@ -34,4 +28,11 @@ public class MyInstantiationAwareBeanPostProcessor extends InstantiationAwareBea
return pvs;
}
// 接口方法实例化Bean之后调用
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
System.out.println("[InstantiationAwareBeanPostProcessorAdapter] call postProcessAfterInitialization");
return bean;
}
}

View File

@ -1,6 +1,7 @@
package io.github.dunwu.spring.core.resources;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;
/**
* 一个 JavaBean 示例
@ -21,33 +22,6 @@ public class Person implements BeanFactoryAware, BeanNameAware, InitializingBean
System.out.println("【构造器】调用Person的构造器实例化");
}
public String getName() {
return name;
}
public void setName(String name) {
System.out.println("【注入属性】注入属性name");
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
System.out.println("【注入属性】注入属性address");
this.address = address;
}
public int getPhone() {
return phone;
}
public void setPhone(int phone) {
System.out.println("【注入属性】注入属性phone");
this.phone = phone;
}
@Override
public String toString() {
return "Person [address=" + address + ", name=" + name + ", phone=" + phone + "]";
@ -79,6 +53,33 @@ public class Person implements BeanFactoryAware, BeanNameAware, InitializingBean
System.out.println("【DiposibleBean接口】调用DiposibleBean.destory()");
}
public String getName() {
return name;
}
public void setName(String name) {
System.out.println("【注入属性】注入属性name");
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
System.out.println("【注入属性】注入属性address");
this.address = address;
}
public int getPhone() {
return phone;
}
public void setPhone(int phone) {
System.out.println("【注入属性】注入属性phone");
this.phone = phone;
}
// 通过<bean>的init-method属性指定的初始化方法
public void myInit() {
System.out.println("【init-method】调用<bean>的init-method属性指定的初始化方法");

View File

@ -28,7 +28,7 @@ public class SpringResoucesTest {
@Test
public void testClassPathXmlApplicationContext2() {
ApplicationContext ctx = new ClassPathXmlApplicationContext(
new String[] {"spring/spring-beans.xml", "spring/spring-beans2.xml"});
new String[] { "spring/spring-beans.xml", "spring/spring-beans2.xml" });
Person zhangsan = ctx.getBean("person_zhangsan", Person.class);
Assert.assertNotNull(zhangsan);
System.out.println(zhangsan);

View File

@ -6,12 +6,12 @@
<parent>
<groupId>io.github.dunwu.spring</groupId>
<artifactId>spring-examples-parent</artifactId>
<artifactId>spring-tutorial-parent</artifactId>
<version>1.0.4</version>
<relativePath>../../spring-examples-parent</relativePath>
<relativePath>../../spring-tutorial-parent</relativePath>
</parent>
<artifactId>spring-examples-core-validation-convert</artifactId>
<artifactId>spring-tutorial-core-validation-convert</artifactId>
<packaging>jar</packaging>
<description>Spring 校验、类型转换示例</description>

View File

@ -1,11 +1,12 @@
package io.github.dunwu.spring.core.convert;
import io.github.dunwu.util.time.DateFormatUtil;
import java.text.ParseException;
import java.util.Date;
import io.github.dunwu.util.time.DateFormatExtUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.convert.converter.Converter;
import java.text.ParseException;
import java.util.Date;
/**
* @author <a href="mailto:forbreak@163.com">Zhang Peng</a>
* @since 2019-06-14
@ -20,7 +21,7 @@ public class StringToDateConverter implements Converter<String, Date> {
Date date = null;
try {
date = DateFormatUtil.parseDate(DateFormatUtil.DatePattern.PATTERN_DEFAULT_ON_SECOND, dateString);
date = DateFormatExtUtils.parseDate(DateFormatExtUtils.DatePattern.PATTERN_DEFAULT_ON_SECOND, dateString);
} catch (ParseException e) {
e.printStackTrace();
}

View File

@ -1,11 +1,12 @@
package io.github.dunwu.spring.core.validation;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.Errors;
import java.beans.PropertyDescriptor;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.Errors;
public abstract class AbstractValidatorRule implements ValidatorRule {

View File

@ -1,9 +1,10 @@
package io.github.dunwu.spring.core.validation;
import org.springframework.expression.ParseException;
import java.lang.annotation.Annotation;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.expression.ParseException;
@ValidRule
public class DateValidatorRule extends AbstractValidatorRule {

Some files were not shown because too many files have changed in this diff Show More