Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lessions
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fukai
lessions
Commits
752c2eb2
Commit
752c2eb2
authored
Jul 19, 2021
by
WeiCong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spring课程
parent
ef96a7ed
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
293 additions
and
0 deletions
+293
-0
spring 常用注解学习.pptx
Spring-lession/spring 常用注解学习.pptx
+0
-0
pom.xml
Spring-lession/springlession/pom.xml
+120
-0
springlession.iml
Spring-lession/springlession/springlession.iml
+48
-0
App.java
Spring-lession/springlession/src/main/java/com/wc/App.java
+13
-0
AnnotationTest.java
...n/src/test/java/com/brilliance/lesson/AnnotationTest.java
+35
-0
BMWCar.java
...sion/src/test/java/com/brilliance/lesson/bean/BMWCar.java
+11
-0
BenzCar.java
...ion/src/test/java/com/brilliance/lesson/bean/BenzCar.java
+11
-0
CarFactory.java
.../src/test/java/com/brilliance/lesson/bean/CarFactory.java
+16
-0
ICar.java
...ession/src/test/java/com/brilliance/lesson/bean/ICar.java
+5
-0
annotationconfig.xml
...ion/springlession/src/test/resources/annotationconfig.xml
+13
-0
componentscan.xml
...ession/springlession/src/test/resources/componentscan.xml
+10
-0
noautowired.xml
...-lession/springlession/src/test/resources/noautowired.xml
+11
-0
No files found.
Spring-lession/spring 常用注解学习.pptx
0 → 100644
View file @
752c2eb2
File added
Spring-lession/springlession/pom.xml
0 → 100644
View file @
752c2eb2
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
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>
<groupId>
com.wc
</groupId>
<artifactId>
springlession
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<name>
springlession
</name>
<!-- FIXME change it to the project's website -->
<url>
http://www.example.com
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<maven.compiler.source>
1.7
</maven.compiler.source>
<maven.compiler.target>
1.7
</maven.compiler.target>
<spring-version>
5.1.9.RELEASE
</spring-version>
<junit.version>
4.12
</junit.version>
<jupiter.version>
5.5.2
</jupiter.version>
<assertj.version>
3.13.2
</assertj.version>
<junit-platform-launcher.version>
1.5.2
</junit-platform-launcher.version>
<mockito.version>
1.10.19
</mockito.version>
<mockito.core.version>
3.0.0
</mockito.core.version>
</properties>
<dependencies>
<!-- Spring核心模块 -->
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-beans
</artifactId>
<version>
${spring-version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context
</artifactId>
<version>
${spring-version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-context-support
</artifactId>
<version>
${spring-version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-core
</artifactId>
<version>
${spring-version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-expression
</artifactId>
<version>
${spring-version}
</version>
</dependency>
<!-- 测试junit5 -->
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
${junit.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.junit.jupiter
</groupId>
<artifactId>
junit-jupiter-api
</artifactId>
<version>
${jupiter.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.junit.jupiter
</groupId>
<artifactId>
junit-jupiter-engine
</artifactId>
<version>
${jupiter.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.junit.vintage
</groupId>
<artifactId>
junit-vintage-engine
</artifactId>
<version>
${jupiter.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.junit.platform
</groupId>
<artifactId>
junit-platform-launcher
</artifactId>
<version>
${junit-platform-launcher.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.assertj
</groupId>
<artifactId>
assertj-core
</artifactId>
<version>
${assertj.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.mockito
</groupId>
<artifactId>
mockito-all
</artifactId>
<version>
${mockito.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.mockito
</groupId>
<artifactId>
mockito-core
</artifactId>
<version>
${mockito.core.version}
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Spring-lession/springlession/springlession.iml
0 → 100644
View file @
752c2eb2
<?xml version="1.0" encoding="UTF-8"?>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"FacetManager"
>
<facet
type=
"Spring"
name=
"Spring"
>
<configuration>
<fileset
id=
"fileset"
name=
"MyTestBean"
removed=
"false"
>
<file>
file://$MODULE_DIR$/src/test/resources/MyTestBean.xml
</file>
</fileset>
</configuration>
</facet>
</component>
<component
name=
"NewModuleRootManager"
LANGUAGE_LEVEL=
"JDK_1_8"
>
<output
url=
"file://$MODULE_DIR$/target/classes"
/>
<output-test
url=
"file://$MODULE_DIR$/target/test-classes"
/>
<content
url=
"file://$MODULE_DIR$"
>
<sourceFolder
url=
"file://$MODULE_DIR$/src/main/java"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/test/java"
isTestSource=
"true"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/test/resources"
type=
"java-test-resource"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/target"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-beans:5.1.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-context:5.1.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-aop:5.1.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-context-support:5.1.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-core:5.1.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-jcl:5.1.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-expression:5.1.9.RELEASE"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: junit:junit:4.12"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.hamcrest:hamcrest-core:1.3"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.junit.jupiter:junit-jupiter-api:5.5.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.apiguardian:apiguardian-api:1.1.0"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.opentest4j:opentest4j:1.2.0"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.junit.platform:junit-platform-commons:1.5.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.junit.jupiter:junit-jupiter-engine:5.5.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.junit.platform:junit-platform-engine:1.5.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.junit.vintage:junit-vintage-engine:5.5.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.junit.platform:junit-platform-launcher:1.5.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.assertj:assertj-core:3.13.2"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.mockito:mockito-all:1.10.19"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.mockito:mockito-core:3.0.0"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: net.bytebuddy:byte-buddy:1.9.10"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: net.bytebuddy:byte-buddy-agent:1.9.10"
level=
"project"
/>
<orderEntry
type=
"library"
scope=
"TEST"
name=
"Maven: org.objenesis:objenesis:2.6"
level=
"project"
/>
</component>
</module>
\ No newline at end of file
Spring-lession/springlession/src/main/java/com/wc/App.java
0 → 100644
View file @
752c2eb2
package
com
.
wc
;
/**
* Hello world!
*
*/
public
class
App
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"Hello World!"
);
}
}
Spring-lession/springlession/src/test/java/com/brilliance/lesson/AnnotationTest.java
0 → 100644
View file @
752c2eb2
package
com
.
brilliance
.
lesson
;
import
com.brilliance.lesson.bean.CarFactory
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.UnsatisfiedDependencyException
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatExceptionOfType
;
public
class
AnnotationTest
{
@Test
public
void
withoutAutowiredAnnotationBeanPostProcessor
()
{
ApplicationContext
context
=
new
ClassPathXmlApplicationContext
(
"noautowired.xml"
);
Object
carFactory
=
context
.
getBean
(
"carFactory"
);
assertThat
(
carFactory
).
isInstanceOf
(
CarFactory
.
class
);
assertThatExceptionOfType
(
NullPointerException
.
class
).
isThrownBy
(()->
carFactory
.
toString
());
}
@Test
public
void
withoutQualifierTest
()
{
assertThatExceptionOfType
(
UnsatisfiedDependencyException
.
class
).
isThrownBy
(()->
new
ClassPathXmlApplicationContext
(
"annotationconfig.xml"
));
}
@Test
public
void
successAutowired
()
{
ApplicationContext
context
=
new
ClassPathXmlApplicationContext
(
"componentscan.xml"
);
Object
carFactory
=
context
.
getBean
(
"cf"
);
assertThat
(
carFactory
.
toString
()).
isEqualTo
(
"BMW car"
);
}
}
Spring-lession/springlession/src/test/java/com/brilliance/lesson/bean/BMWCar.java
0 → 100644
View file @
752c2eb2
package
com
.
brilliance
.
lesson
.
bean
;
import
org.springframework.stereotype.Component
;
@Component
(
"bm"
)
public
class
BMWCar
implements
ICar
{
public
String
getCarName
()
{
return
"BMW car"
;
}
}
Spring-lession/springlession/src/test/java/com/brilliance/lesson/bean/BenzCar.java
0 → 100644
View file @
752c2eb2
package
com
.
brilliance
.
lesson
.
bean
;
import
org.springframework.stereotype.Component
;
@Component
(
"bz"
)
public
class
BenzCar
implements
ICar
{
public
String
getCarName
()
{
return
"Benz car"
;
}
}
Spring-lession/springlession/src/test/java/com/brilliance/lesson/bean/CarFactory.java
0 → 100644
View file @
752c2eb2
package
com
.
brilliance
.
lesson
.
bean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.stereotype.Component
;
@Component
(
"cf"
)
public
class
CarFactory
{
@Autowired
@Qualifier
(
"bm"
)
private
ICar
car
;
public
String
toString
(){
return
car
.
getCarName
();
}
}
Spring-lession/springlession/src/test/java/com/brilliance/lesson/bean/ICar.java
0 → 100644
View file @
752c2eb2
package
com
.
brilliance
.
lesson
.
bean
;
public
interface
ICar
{
public
String
getCarName
();
}
Spring-lession/springlession/src/test/resources/annotationconfig.xml
0 → 100644
View file @
752c2eb2
<?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"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
>
<!-- 使用annotation-config,增加四类后置处理器,但是默认使用的是SimpleAutowireCandidateResolver -->
<context:annotation-config/>
<bean
id=
"benzCar"
class=
"com.brilliance.lesson.bean.BenzCar"
/>
<bean
id=
"bmwCar"
class=
"com.brilliance.lesson.bean.BMWCar"
/>
<bean
id=
"carFactory"
class=
"com.brilliance.lesson.bean.CarFactory"
/>
</beans>
\ No newline at end of file
Spring-lession/springlession/src/test/resources/componentscan.xml
0 → 100644
View file @
752c2eb2
<?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"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
>
<!-- 使用component-scan会扫描标注有@Component注入到容器中,增加四类后置处理器且使用了QualifierAnnotationAutowireCandidateResolver -->
<context:component-scan
base-package=
"com.brilliance.lesson.bean"
/>
</beans>
\ No newline at end of file
Spring-lession/springlession/src/test/resources/noautowired.xml
0 → 100644
View file @
752c2eb2
<?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"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
>
<bean
id=
"benzCar"
class=
"com.brilliance.lesson.bean.BenzCar"
/>
<bean
id=
"bmwCar"
class=
"com.brilliance.lesson.bean.BMWCar"
/>
<bean
id=
"carFactory"
class=
"com.brilliance.lesson.bean.CarFactory"
/>
</beans>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment