我想用spring boot 开发web程序,在创建工程的时候需要引入哪些依赖
时间: 2024-04-07 21:27:34 浏览: 16
如果你想使用Spring Boot开发Web程序,你可以在创建工程的时候引入以下依赖:
1. spring-boot-starter-web:这是Spring Boot Web应用开发的基本依赖,包含Spring MVC和Tomcat等常用的Web组件。
2. spring-boot-starter-thymeleaf:这是一个模板引擎,可以帮助你生成HTML页面。
3. spring-boot-starter-data-jpa:这是使用JPA进行数据持久化的依赖。
4. spring-boot-starter-security:这是Spring Security安全框架的依赖。
5. spring-boot-starter-test:这是Spring Boot测试框架的依赖,可以帮助你编写单元测试和集成测试。
你可以在Maven或Gradle的配置文件中添加这些依赖,然后使用相应的注解和配置来开发Web应用程序。同时,你还可以根据自己的需求添加其他依赖,例如数据库驱动、缓存组件等。
相关问题
spring-boot-starter-web和starter
spring-boot-starter-web和spring-boot-starter是Spring Boot中的两个核心启动器之一。
引用提到,当我们在Spring Boot项目的pom.xml中引入了spring-boot-starter-web的依赖时,就无需再引入spring-boot-starter核心启动器的依赖了。这是因为spring-boot-starter-web已经包含了spring-boot-starter的功能。
而引用展示了在创建一个Spring Boot工程时,如何在pom.xml中添加spring-boot-starter-web的依赖。
引用提到,只要我们在Spring Boot项目的pom.xml中引入了spring-boot-starter-web,即使不进行任何配置,也可以直接使用Spring MVC进行Web开发。
综上所述,spring-boot-starter-web是一个方便快速开发Web应用的启动器,它包含了Spring MVC框架所需的依赖以及自动配置。而spring-boot-starter是Spring Boot的核心启动器,它提供了一些基本的功能和依赖,供其他更具体的启动器使用。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [spring-boot-starter-web(Web启动器)](https://blog.csdn.net/youandme520/article/details/122834888)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
Could not find artifact org.springframework.boot:spring-boot-starter-web:pom:unknown in central
在创建Spring Boot工程时,你引入了org.springframework.boot的spring-boot-starter-parent和spring-boot-starter-web,但是在使用阿里云的maven仓库时,提示找不到spring-boot-starter-parent的jar包,而spring-boot-starter-web的jar包可以找到。这是因为maven仓库中没有spring-boot-starter-parent相关的jar包,所以需要在依赖中指定type为pom。你可以通过添加以下依赖来解决问题:
```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.7</version>
<type>pom</type>
</dependency>
```
这样就可以在阿里云的maven仓库中找到并引入spring-boot-starter-parent的相关jar包了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [Could not find artifact org.springframework.boot:spring-boot-starter-parent:jar](https://blog.csdn.net/a1004314120/article/details/128584548)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]