• Spring Boot


    • Application.java启动类
      • 用@SpringBootApplication标识Application.java启动类
        • @SpringBootApplication相当于@Configuration + @EnableAutoConfiguration + @ComponentScan
          • @Configuration: Tags the class as a source of bean definitions for the application context.
          • @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 annotation flags the application as a web application and activates key behaviors, such as setting up a DispatcherServlet.
          • @ComponentScan: Tells Spring to look for other components, configurations, and services in the hello package, letting it find the controllers.
        • 可以通过scanBasePackages指定要扫描的包,相当于@ComponentScan,如@SpringBootApplication(scanBasePackages = {"com.yyy", "com.xxx" })
      • 其实最终使用了Spring Boot提供的启动方法:SpringApplication.run(Application.class, args);
    • 打包运行
      • 可以使用Gradle、Maven来运行、打包程序
      • 默认打包成可执行的jar包,并包含一个内嵌的servlet容器 - Tomcat作为Http runtime。
      • jar包中的Main函数就是前面用@SpringBootApplication标识的Application.java启动类
      • 运行jar包:java -jar xxx.jar
    • 启动并指定用哪个profile
      • 从Spring Boot项目根目录启动时指定:java org.springframework.boot.loader.JarLauncher —spring.profiles.active=xxx
      • 启动jar包时指定:java -Dspring.profiles.active=xxx -jar yyy.jar
  • 相关阅读:
    Telnet登陆网络设备执行命令脚本
    Python发送飞书消息
    百度贴吧爬虫
    notpadd++ 颜色
    git 快速解决冲突 工具
    go strconv模块
    Day 03 strings 和 strconv 的使用, 时间和日期类型 流程控制 函数
    go 的flag用法
    Python schedules.crontab方法代码示例 https://vimsky.com/examples/detail/pythonmethodcelery.schedules.crontab.html
    go bufio和fmt.Scanf()用法
  • 原文地址:https://www.cnblogs.com/wyp1988/p/11528095.html
Copyright © 2020-2023  润新知