springboot 引入xml配置
来源:互联网 发布:手机游戏盒子软件 编辑:程序博客网 时间:2024/06/07 02:02
package smaug.service.provider.starts;
import org.glassfish.jersey.servlet.ServletContainer;
import org.glassfish.jersey.servlet.ServletProperties;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportResource;
import smaug.service.config.jerseyConfig.AnnotationJerseyConfig;
/**
* Created by naonao on 17/7/9.
*/
@SpringBootApplication
@ComponentScan(value = {“smaug.service”, “smaug.util”, “smaug.config”}) // 将接口在启动的时候注册进来
@EnableAutoConfiguration
@MapperScan(“smaug.service.provider.mapper”)
//@ImportResource(locations = {“classpath:spring-order-context.xml”, “classpath:spring-order-context.xml”})
@ImportResource(locations = {“classpath:spring-order-context.xml”})
public class OrderStartApplication {
public static void main(String[] args) {
SpringApplication.run(OrderStartApplication.class, args);
}
@Beanpublic ServletRegistrationBean jerseyServlet() { ServletRegistrationBean registration = new ServletRegistrationBean(new ServletContainer(), "/*"); registration.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, AnnotationJerseyConfig.class.getName()); return registration;}
}
location 导入配置有两种方法
- 就像上文使用classpath那样
-全局路径 @ImportResource(locations={“file:d:/test/application-bean1.xml”})
还有一点就是
@SpringBootApplication 注解等价于以默认属性使用 @Configuration , @EnableAutoConfiguration 和 @ComponentScan 。
那上面那个的注解又可以简化成
@SpringBootApplication(scanBasePackages = {"smaug.service", "smaug.util", "smaug.config"})@EnableAutoConfiguration@MapperScan("smaug.service.provider.mapper")//@ImportResource(locations = {"classpath:spring-order-context.xml", "classpath:spring-order-context.xml"})@ImportResource(locations = {"classpath:spring-order-context.xml"})
- springboot 引入xml配置
- SpringBoot 配置 web.xml
- web.xml中引入其他配置
- Spring的XML配置引入XML Schema语法简化配置
- 第二十五章 SpringBoot导入XML配置
- SpringBoot整合Dubbox(无XML配置)
- springboot整合mybatis xml方式配置SQL
- SpringBoot 无XML的相关配置
- spring.xml从外部文件引入数据库配置信息
- springboot引入外部jar包
- springboot 工程引入Mongodb 简述
- SpringBoot、MyBatis配置多数据源XML方法
- jAVA SpringBoot(1)---pom.xml文件基本配置
- Springboot多realm集成,无ini文件,无xml配置
- SpringBoot集成MyBatis时要配置的Mapper中的xml
- java鬼混笔记:springboot 10、springboot logback-spring.xml简单的日志配置
- springboot配置
- springboot配置
- BZOJ2152[聪聪可可] 点分治
- Atitit 知识点的体系化 框架与方法 如何了解 看待xxx
- 结构体
- 2181: GJJ的日常之暴富梦
- JVM(2):JVM内存结构
- springboot 引入xml配置
- 例2-20 将-100~100的序号序列给出的正弦信号压缩、扩展2倍并与元信号进行比较,时间间隔是0.3s
- sqlnet.ora 参数
- Logistic回归
- plugman phonegap插件开发最新问题
- spring入门--搭建步骤
- OpenCV学习笔记(二)——新版本模块结构
- 抽象类&接口
- 如何移除Chrome浏览器让人不爽的GoogleUpdate.exe后台更新进程