Spring 笔记

src/main/java/hello/Application.java

package hello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }
}

@SpringBootApplication 是一个很方便的注解,它包含了以下三个注解的功能(详见该注解源码):

  • @Configuration tags the class as a source of bean definitions for the application context.
    将该类标记为Bean定义的源

  • @EnableAutoConfiguration tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings. For example, if spring-webmvc is on the classpath this flags the application as a web application and activates key behaviors such as setting up a DispatcherServlet.
    告知 SpringBoot 添加这些 Beans (这些 Beans 是由 classpath settings, other beans, and various property settings 定义的),例如,译略...

  • @ComponentScan tells Spring to look for other components, configurations, and services in the hello package, allowing it to find the controllers.
    告知 SpringBoot 在包 hello 中去寻找其他 components, configurations, and services, 从而让它找到对应的 controllers

The main() method uses Spring Boot’s SpringApplication.run() method to launch an application. Did you notice that there wasn’t a single line of XML? No web.xml file either. This web application is 100% pure Java and you didn’t have to deal with configuring any plumbing or infrastructure.
这个 Main() 使用了 SpringBoot 的 SpringApplication.run() 来启动这个应用。因此这里不需要任何 xml 配置,百分百的纯 Java 代码。

For demonstration purposes, there is code to create a JdbcTemplate, query the database, and print out the names of people the batch job inserts. 由于这里仅作示例,译略...

另外,个人推荐在简单例子中使用 文件式数据库 做练习,因为这样可以避免污染 MySQL 等。

转载于:https://www.cnblogs.com/yucloud/p/11351463.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值