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 等。

    --------蓝天上的云_转载请注明出处.
  • 相关阅读:
    呵呵
    数据类型转换方法
    工业设计三原则
    C#实现的根据年月日计算星期几的函数
    网页设计的12种颜色
    SqlParameter 存储过程
    HTTP 状态响应码
    Android获取屏幕高度和宽度
    Android屏幕自适应解决方案
    Nodejs学习笔记nodejs的安装
  • 原文地址:https://www.cnblogs.com/yucloud/p/11351463.html
Copyright © 2011-2022 走看看