加载XML配置
This commit is contained in:
parent
f557cca7cc
commit
2a27fc43e2
|
|
@ -16,4 +16,10 @@ Any value defined here will override the pom.xml file value but is only applicab
|
|||
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.6-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
|
||||
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>Tomcat</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
|
||||
</properties>
|
||||
<spring-data xmlns="http://www.netbeans.org/ns/spring-data/1">
|
||||
<config-files>
|
||||
<config-file>src/main/resources/minaConfig.xml</config-file>
|
||||
</config-files>
|
||||
<config-file-groups/>
|
||||
</spring-data>
|
||||
</project-shared-configuration>
|
||||
|
|
|
|||
|
|
@ -20,11 +20,13 @@ import org.apache.mina.filter.codec.ProtocolCodecFilter;
|
|||
import org.apache.mina.filter.logging.LoggingFilter;
|
||||
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Configuration
|
||||
public class MinaConfig {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@
|
|||
package com.ifish.config;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
import org.springframework.web.filter.CharacterEncodingFilter;
|
||||
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
|
||||
|
||||
|
|
@ -18,7 +20,7 @@ public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServlet
|
|||
|
||||
@Override
|
||||
protected Class<?>[] getRootConfigClasses() {
|
||||
return new Class<?>[]{RootConfig.class, MybatisConfig.class,MinaConfig.class};
|
||||
return new Class<?>[]{RootConfig.class, MybatisConfig.class, MinaConfig.class, applicationContext().getClass()};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -36,6 +38,12 @@ public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServlet
|
|||
return null;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ApplicationContext applicationContext() {
|
||||
ApplicationContext ct = new FileSystemXmlApplicationContext(this.getClass().getClassLoader().getResource("minaConfig.xml").getFile());
|
||||
return ct;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Filter characterEncodingFilter() {
|
||||
CharacterEncodingFilter filter = new CharacterEncodingFilter();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
<?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:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:c="http://www.springframework.org/schema/c"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:flow="http://www.springframework.org/schema/webflow-config"
|
||||
xmlns:jee="http://www.springframework.org/schema/jee"
|
||||
xmlns:jms="http://www.springframework.org/schema/jms"
|
||||
xmlns:lang="http://www.springframework.org/schema/lang"
|
||||
xmlns:osgi="http://www.springframework.org/schema/osgi"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
|
||||
http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
|
||||
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.3.xsd
|
||||
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-4.3.xsd
|
||||
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-4.3.xsd
|
||||
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-1.2.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd
|
||||
">
|
||||
|
||||
</beans>
|
||||
Loading…
Reference in New Issue