第3讲 SpringBoot项目目录介绍

161 阅读2分钟

创建好了SpringBoot工程之后,我们看看项目结构

48347C2A-C0A7-45A4-B182-487C4AA4DE2B.png 这个结构看起来非常的熟悉,如果之前一直使用的是maven来进行项目管理的话。

基本没有什么差别,好像没什么介绍的

这里需要注意的是main目录下面

有一个resources目录

88CAFB73-4B06-4927-921E-C983660D10C0.png static目录下面是存放静态文件的,比如js,image等

templates下面是存放页面资源等

application.properties 是SpringBoot的唯一配置文件,核心文件。

在java的类目录下,SpringBoot为我们自动创建了一个类

SpringbootApplication.java


@SpringBootApplication  // SpringBoot 核心注解,主要用于开启spring自动配置

public class SpringbootApplication {


    public static void main(String[] args) {

        SpringApplication.run(SpringbootApplication.class, args);

    }


}

这个类是SpringBoot的核心类

我们直接运行这个main方法,也就启动了SpringBoot的服务

  .   ____          _            __ _ _

/\ / _' __ _ () __  __ _ \ \ \ \

( ( )___ | '_ | '| | ' / _` | \ \ \ \

\/  __)| |)| | | | | || (_| |  ) ) ) )

  '  |__| .__|| ||| |__, | / / / /

=========||==============|__/=///_/

:: Spring Boot ::                (v2.4.1)

2020-12-15 17:38:24.144  INFO 3695 --- [           main] c.d.springboot.SpringbootApplication     : Starting SpringbootApplication using Java 1.8.0_251 on JaydeMacBook-Pro.local with PID 3695 (/Users/jay/IdeaProjects/springboot/target/classes started by jay in /Users/jay/IdeaProjects/springboot)

2020-12-15 17:38:24.146  INFO 3695 --- [           main] c.d.springboot.SpringbootApplication     : No active profile set, falling back to default profiles: default

2020-12-15 17:38:24.657  INFO 3695 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)

2020-12-15 17:38:24.662  INFO 3695 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]

2020-12-15 17:38:24.662  INFO 3695 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]

2020-12-15 17:38:24.701  INFO 3695 --- [           main] o.a.c.c.C.[.[localhost].[/springboot]    : Initializing Spring embedded WebApplicationContext

2020-12-15 17:38:24.701  INFO 3695 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 528 ms

2020-12-15 17:38:24.794  INFO 3695 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'

2020-12-15 17:38:24.914  INFO 3695 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path '/'

2020-12-15 17:38:24.922  INFO 3695 --- [           main] c.d.springboot.SpringbootApplication     : Started SpringbootApplication in 1.011 seconds (JVM running for 1.385)

2020-12-15 17:38:29.918  INFO 3695 --- [nio-8090-exec-1] o.a.c.c.C.[.[localhost].[/springboot]    : Initializing Spring DispatcherServlet 'dispatcherServlet'

2020-12-15 17:38:29.919  INFO 3695 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'

2020-12-15 17:38:29.919  INFO 3695 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 0 ms

这样SpringBoot项目就起来的,看到了启动了Tomcat服务,端口是8080

当然这些都是可以修改的,后面我们会讲解如何修改端口以及上下文。