标签:ica 读取配置 files ring ack instance schema new https
ApplicationContext ac=new AnnotationApplicationContext("MyConfig.class")
package com.example.demo;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan("com.example.demo")
public class MyConfig {
}
读取applicationContext.xml的两种方式:
ApplicationContext ac=new ClassPathApplicationContext("applicationContext.xml")
ApplicationContext ac=new FileSystemXmlApplicationContext("F:/config/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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<bean class="com.example.demo.controller.UserController" id="userController"/>
<context:component-scan base-package="com.example.demo"/>
</beans>
补充:
标签:ica 读取配置 files ring ack instance schema new https
原文地址:https://www.cnblogs.com/kwdlh/p/13235975.html