spring boot 依赖注入
来源:互联网 发布:php新闻发布系统登录 编辑:程序博客网 时间:2024/05/29 08:35
一.创建maven工程,编写pom.xml文件
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.4.1.RELEASE</version></parent><properties><java.version>1.8</java.version><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><!-- 添加依赖的jar包 --><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies>二.创建Application.java程序入口类
//@ComponentScan//自动扫描bean//@EnableAutoConfiguration @SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScanpublic class Application {public static void main(String[] args) throws Exception {// 启动SpringApplication.run(Application.class, args);}}三.创建SimpleService.java
@Servicepublic class SimpleService {public String say(){return "hello world";}}四.创建SimpleController.java在其中注入SimpleService
@RestControllerpublic class SimpleController {@Autowired // 自动注入private SimpleService service;@RequestMapping("/")public String home() {return service.say();}}
五.启动应用,打开浏览器输入localhost:8080就可以访问到hello world
源码链接https://github.com/wangjianyangchn/SpringBootProject
0 1
- spring boot 依赖注入
- Spring Boot 依赖注入
- spring boot项目依赖spring mvc项目注入失败问题
- Spring Boot参考文档(9)依赖注入
- spring boot 多模块管理时,依赖注入bean失败
- Spring依赖注入:注解注入
- spring 的依赖注入
- Spring依赖注入实践经验
- Spring的依赖注入
- Spring依赖注入
- spring(依赖注入-DI)
- spring依赖注入
- spring依赖注入
- 白话spring依赖注入
- Spring依赖注入方式
- Spring的依赖注入
- Spring依赖注入
- Spring依赖注入方式
- Groovy 生成xml文件(使用MarkupBuilder)
- 背景建模总结
- Shell中脚本变量和函数变量的作用域
- DPI 深度报文检测
- Unsupervised Representation to Predict the Future of Patients from the Electronic Health Records
- spring boot 依赖注入
- Android三种播放视频的方式
- 完美解决XP无法定位程序输入点RegGetValue于动态链接库ADVAPI32.dll,XP,win7注册表读取问题
- 丰乐河电站调速发货
- 卖地和炒房一样都会上瘾的
- 机器学习通用框架
- 协议栈
- JavaWeb框架数据传输乱码问题解决
- 用化学绘图软件连接两个结构片段的方法