在哪里可以找到示例 applicationContext.xml 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28414234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where can I find the example applicationContext.xml file
提问by Anshul
With Spring 3 distribution there was a project folder which was packaged in the distribution . This project folder had sample applicationContext.xmlfile which can be used . However when I have downloaded Spring 4 distribution from hereit does not come with a project folder and I am not able to find the sample applicationContext.xml. Where can I find the example applicationContext.xmlfile.
在 Spring 3 发行版中,有一个项目文件夹打包在发行版中。这个项目文件夹有applicationContext.xml可以使用的示例文件。但是,当我从这里下载 Spring 4 发行版时,它没有附带项目文件夹,而且我找不到示例applicationContext.xml。我在哪里可以找到示例applicationContext.xml文件。
回答by erhun
You can use this for further information check here.
您可以在此处使用它获取更多信息。
Below sample contains configuration as follows:
下面的示例包含如下配置:
- component-scan base com.foo which thinking as your root folder.
- Basic dataSource definition.
- Property place holder file(database.properties)
- Message Source for localization support.
- component-scan base com.foo 将其视为您的根文件夹。
- 基本数据源定义。
- 属性占位符文件(database.properties)
- 用于本地化支持的消息源。
sample ApplicationContext.xml
示例 ApplicationContext.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:c="http://www.springframework.org/schema/c"
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<context:property-placeholder location="classpath:/database.properties" />
<context:component-scan base-package="com.foo" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="initialSize" value="5" />
<property name="maxActive" value="10" />
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages" />
</bean>
</beans>

