Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f0576c
commit f388859
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...ial/tutorial-guava/src/main/java/org/xspring/tutorial/guava/GuavaTutorialApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.xspring.tutorial.guava; | ||
|
||
import org.springframework.beans.factory.support.BeanDefinitionRegistry; | ||
import org.springframework.beans.factory.support.DefaultListableBeanFactory; | ||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; | ||
import org.springframework.core.io.ClassPathResource; | ||
|
||
/** | ||
* <p>Title: GuavaTutorialApplication</p> | ||
* <p>Description:</p> | ||
* <p>Copyright: Ruijie Co., Ltd. (c) 2018</p> | ||
* <p>@Author: chenzhian </p> | ||
* <p>@Date: 2018/7/23 下午2:42</p> | ||
*/ | ||
public class GuavaTutorialApplication { | ||
public static void main(String[] args) { | ||
BeanDefinitionRegistry beanFactory = new DefaultListableBeanFactory(); | ||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory); | ||
ClassPathResource resource = new ClassPathResource("bean.xml"); | ||
|
||
reader.loadBeanDefinitions(resource); | ||
|
||
String str = (String) ((DefaultListableBeanFactory) beanFactory).getBean("demo_str"); | ||
System.out.println("str bean:" + str); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
xspring-tutorial/tutorial-guava/src/main/resources/bean.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?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:tx="http://www.springframework.org/schema/tx" | ||
xsi:schemaLocation=" | ||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | ||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/beans/spring-tx.xsd"> | ||
|
||
<tx:annotation-driven /> | ||
|
||
<bean id="demo_str" class="java.lang.String"/> | ||
|
||
</beans> |