Where can I find an example applicationContext.xml file

With the Spring 3 distribution, there was a project folder that was packaged in the distribution. There was an example applicationContext.xml file in this project folder that could be used. However, when I downloaded the Spring 4 distribution from here , it does not come with the project folder, and I cannot find a sample applicationContext.xml . Where can I find an example applicationContext.xml file.

+8
spring xml spring-mvc applicationcontext
source share
1 answer

You can use this for more information to check here .

The below sample contains the configuration as follows:

  • scan component of the com.foo base, which examines your root folder.
  • Master data Source definition.
  • Storage Owner File (database.properties)
  • Message source to support localization.

sample 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> 
+11
source share

All Articles