zoukankan      html  css  js  c++  java
  • 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 等。

    --------蓝天上的云_转载请注明出处.
  • 相关阅读:
    【Javascript】JS单例模式的简单实现
    【Javascript】Javascript中如何判断变量是数组类型
    买卖股票的最佳时机 II
    只出现一次的数字
    删除排序数组中的重复项
    两数之和
    Android系统中Fastboot和Recovery所扮演的角色。
    虚函数、纯虚函数、抽象类、接口 (Java_C++_C#)
    关于cmd中执行命令路径包含空格的解决办法
    Windows API 编程学习记录<三>
  • 原文地址:https://www.cnblogs.com/yucloud/p/11351463.html
Copyright © 2011-2022 走看看