23.1 SpringApplication spring boot 启动

springApplication  提供启动类的main方法,在许多情况下,您可以将其委托给静态spring应用程序。运行方法:

public static void main(String[] args) throws Exception {
    //设置 热启动不生效 也可以在 资源文件中配置spring.devtools.restart.enabled
    //   System.setProperty("spring.devtools.restart.enabled", "false");
    //SpringApplication.run(Example.class, args);


    SpringApplication application = new SpringApplication(Example.class);
           /*
            * Banner.Mode.OFF:关闭;
            * Banner.Mode.CONSOLE:控制台输出,默认方式;
            * Banner.Mode.LOG:日志输出方式;
            */
    //application.setBannerMode(Banner.Mode.OFF);
    application.run(args);
}

 当启动后,可以查看日志系统

┬┴┬/ ̄\_/ ̄\
┬┴┬┴▏  ▏▔▔▔▔\
┴┬┴/\ /      ﹨
┬┴∕       /   )
┴┬▏        ●  ▏
┬┴▏           ▔█ 
┴◢██◣      \__/   !
┬█████◣       /  
┴█████████████◣
◢██████████████▆▄
█◤◢██◣◥█████████◤\
◥◢████ ████████◤   \
┴█████ ██████◤      ﹨
┬│   │█████◤         ▏
┴│   │               ▏
┬∕   ∕    /▔▔▔\     ∕
┴/___/﹨   ∕     ﹨  /\


#这个是springboot的版本号
1.5.4.RELEASE
#这个是springboot的版本号
 (v1.5.4.RELEASE)
2017-06-10 13:24:25.406  INFO 69788 --- [  restartedMain] com.csg.Example                          : Starting Example on DESKTOP-F36IHM2 with PID 69788 (J:\work1\target\classes started by csg in J:\work1)
2017-06-10 13:24:25.406  INFO 69788 --- [  restartedMain] com.csg.Example                          : No active profile set, falling back to default profiles: default
2017-06-10 13:24:25.408  INFO 69788 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@4fc2d46b: startup date [Sat Jun 10 13:24:25 CST 2017]; root of context hierarchy
2017-06-10 13:24:25.568  INFO 69788 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 1111 (http)
2017-06-10 13:24:25.568  INFO 69788 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2017-06-10 13:24:25.568  INFO 69788 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.15
2017-06-10 13:24:25.577  INFO 69788 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext


会记录下启动的每一个过程

启动失败后,也会有相应的错误描述信息。


***************************
APPLICATION FAILED TO START
***************************

Description:

The Tomcat connector configured to listen on port 1111 failed to start. The port may already be in use or the connector may be misconfigured.

Action:

Verify the connector's configuration, identify and stop any process that's listening on port 1111, or configure this application to listen on another port.


### 配置 JDK 21 项目在 IntelliJ IDEA 2023.1 中 IntelliJ IDEA 2023.1 支持配置和使用 JDK 21,尽管 Spring Boot 的最新版本目前不兼容 Java 20[^1]。通过适当的配置,可以在 IntelliJ IDEA 中成功运行基于 JDK 21 的项目。 #### 配置 JDK 21 的步骤 1. 确保 JDK 21 已安装在系统中,并且环境变量配置正确。 2. 打开 IntelliJ IDEA,进入 **File > Project Structure > SDKs**,点击 **+** 添加新的 SDK。 3. 选择 JDK 的安装路径,例如 `C:\Program Files\Java\jdk-21`。 4. 在 **Project** 选项卡中,选择刚刚添加的 JDK 21 作为项目的 SDK。 5. 在 **Build, Execution, Deployment > Compiler > Java Compiler** 中,确保编译器版本与 JDK 21 兼容。 #### 配置项目语言级别 1. 进入 **File > Settings > Build, Execution, Deployment > Compiler > Java Compiler**。 2. 设置 **Target bytecode version** 为 21。 3. 在 **Editor > Language Levels** 中,选择 **SDK Default (21 - Pattern Matching for Switch)** 以确保支持 JDK 21 的新特性。 #### 启动项目 1. 确保项目的 `pom.xml` 或 `build.gradle` 文件中配置的 Java 版本为 21。 ```xml <properties> <maven.compiler.source>21</maven.compiler.source> <maven.compiler.target>21</maven.compiler.target> </properties> ``` 2. 在 IntelliJ IDEA 中运行项目时,确保运行配置中使用的是 JDK 21。 3. 如果项目依赖 Spring Boot,需要确认其版本是否支持 Java 21。目前 Spring Boot 的某些版本可能仍不兼容 Java 20 及以上版本。 #### 注意事项 - 在某些情况下,使用 JDK 21 时可能会遇到插件兼容性问题,尤其是某些老旧插件可能未更新以支持 JDK 21。 - 如果项目使用了 Lombok 或其他依赖于编译器插件的库,确保这些插件已更新以支持 JDK 21。 ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值