Spring Boot项目的创建

在这里插入图片描述

hi 大家好,又见面了,今天继续讲解Spring Boot

文章目录

  • 🐶1.什么是Spring Boot?
  • 🐶2.Spring Boot的优势
  • 🐶3.Spring Boot项目创建
    • 🌼3.1使用ieda创建
      • 🥝3.1.1下载插件Spring Boot Helper
      • 🥝3.1.2创建项目
    • 🌼3.2使用网页创建
  • 🐶4.Spring Boot目录工程介绍
  • 🐶5.使用Spring Boot写一个最简单的程序
  • 🐶6.Spring Boot和Spring做对比

🐶1.什么是Spring Boot?

Spring 的诞⽣是为了简化 Java 程序的开发的,⽽ Spring Boot 的诞⽣是为了简化 Spring 程序开发的。
Spring Boot是基于Spring框架的一个轻量级开发框架,目的是让开发Spring应用变得更加简单快捷.
Spring Boot是Spring脚手架,就是为了快速开发 Spring 框架⽽诞⽣的
比如盖房子用脚手架让盖房子更高效哈哈~

🐶2.Spring Boot的优势

快速集成框架,Spring Boot 提供了启动添加依赖的功能,⽤于秒级集成各种框架。
内置运⾏容器,⽆需配置 Tomcat 等 Web 容器,直接运⾏和部署程序。
快速部署项⽬,⽆需外部容器即可启动并运⾏项⽬。
可以完全抛弃繁琐的 XML,使⽤注解和配置的⽅式进⾏开发。
⽀持更多的监控的指标,可以更好的了解项⽬的运⾏情况。

🐶3.Spring Boot项目创建

🌼3.1使用ieda创建

🥝3.1.1下载插件Spring Boot Helper

在这里插入图片描述

🥝3.1.2创建项目

在这里插入图片描述
在这里插入图片描述
添加依赖
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
第一次创建Spring Boot项目要加载很久,因为当前Spring Boot项目并没有在本地仓库,而且要保证在创建前配置了maven国内源,如果没有配置,下方为大家提供国内seetings.xml的信息

<?xml version="1.0" encoding="UTF-8"?><!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
--><!--| This is the configuration file for Maven. It can be specified at two levels:||  1. User Level. This settings.xml file provides configuration for a single user,|                 and is normally provided in ${user.home}/.m2/settings.xml.||                 NOTE: This location can be overridden with the CLI option:||                 -s /path/to/user/settings.xml||  2. Global Level. This settings.xml file provides configuration for all Maven|                 users on a machine (assuming they're all using the same Maven|                 installation). It's normally provided in|                 ${maven.conf}/settings.xml.||                 NOTE: This location can be overridden with the CLI option:||                 -gs /path/to/global/settings.xml|| The sections in this sample file are intended to give you a running start at| getting the most out of your Maven installation. Where appropriate, the default| values (values used when the setting is not specified) are provided.||-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"><!-- localRepository| The path to the local repository maven will use to store artifacts.|| Default: ${user.home}/.m2/repository<localRepository>/path/to/local/repo</localRepository>--><!-- interactiveMode| This will determine whether maven prompts you when it needs input. If set to false,| maven will use a sensible default value, perhaps based on some other setting, for| the parameter in question.|| Default: true<interactiveMode>true</interactiveMode>--><!-- offline| Determines whether maven should attempt to connect to the network when executing a build.| This will have an effect on artifact downloads, artifact deployment, and others.|| Default: false<offline>false</offline>--><!-- pluginGroups| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.| when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.|--><pluginGroups><!-- pluginGroup| Specifies a further group identifier to use for plugin lookup.<pluginGroup>com.your.plugins</pluginGroup>--></pluginGroups><!-- proxies| This is a list of proxies which can be used on this machine to connect to the network.| Unless otherwise specified (by system property or command-line switch), the first proxy| specification in this list marked as active will be used.|--><proxies><!-- proxy| Specification for one proxy, to be used in connecting to the network.|<proxy><id>optional</id><active>true</active><protocol>http</protocol><username>proxyuser</username><password>proxypass</password><host>proxy.host.net</host><port>80</port><nonProxyHosts>local.net|some.host.com</nonProxyHosts></proxy>--></proxies><!-- servers| This is a list of authentication profiles, keyed by the server-id used within the system.| Authentication profiles can be used whenever maven must make a connection to a remote server.|--><servers><!-- server| Specifies the authentication information to use when connecting to a particular server, identified by| a unique name within the system (referred to by the 'id' attribute below).|| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are|       used together.|<server><id>deploymentRepo</id><username>repouser</username><password>repopwd</password></server>--><!-- Another sample, using keys to authenticate.<server><id>siteServer</id><privateKey>/path/to/private/key</privateKey><passphrase>optional; leave empty if not used.</passphrase></server>--></servers><!-- mirrors| This is a list of mirrors to be used in downloading artifacts from remote repositories.|| It works like this: a POM may declare a repository to use in resolving certain artifacts.| However, this repository may have problems with heavy traffic at times, so people have mirrored| it to several places.|| That repository definition will have a unique id, so we can create a mirror reference for that| repository, to be used as an alternate download site. The mirror site will be the preferred| server for that repository.|--><mirrors><mirror><id>alimaven</id><name>aliyun maven</name><url>http://maven.aliyun.com/nexus/content/groups/public/</url><mirrorOf>central</mirrorOf>        </mirror><!-- mirror| Specifies a repository mirror site to use instead of a given repository. The repository that| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.|<mirror><id>mirrorId</id><mirrorOf>repositoryId</mirrorOf><name>Human Readable Name for this Mirror.</name><url>http://my.repository.com/repo/path</url></mirror>--></mirrors><!-- profiles| This is a list of profiles which can be activated in a variety of ways, and which can modify| the build process. Profiles provided in the settings.xml are intended to provide local machine-| specific paths and repository locations which allow the build to work in the local environment.|| For example, if you have an integration testing plugin - like cactus - that needs to know where| your Tomcat instance is installed, you can provide a variable here such that the variable is| dereferenced during the build process to configure the cactus plugin.|| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles| section of this document (settings.xml) - will be discussed later. Another way essentially| relies on the detection of a system property, either matching a particular value for the property,| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.| Finally, the list of active profiles can be specified directly from the command line.|| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact|       repositories, plugin repositories, and free-form properties to be used as configuration|       variables for plugins in the POM.||--><profiles><!-- profile| Specifies a set of introductions to the build process, to be activated using one or more of the| mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>| or the command line, profiles have to have an ID that is unique.|| An encouraged best practice for profile identification is to use a consistent naming convention| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.| This will make it more intuitive to understand what the set of introduced profiles is attempting| to accomplish, particularly when you only have a list of profile id's for debug.|| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.<profile><id>jdk-1.4</id><activation><jdk>1.4</jdk></activation><repositories><repository><id>jdk14</id><name>Repository for JDK 1.4 builds</name><url>http://www.myhost.com/maven/jdk14</url><layout>default</layout><snapshotPolicy>always</snapshotPolicy></repository></repositories></profile>--><!--| Here is another profile, activated by the system property 'target-env' with a value of 'dev',| which provides a specific path to the Tomcat instance. To use this, your plugin configuration| might hypothetically look like:|| ...| <plugin>|   <groupId>org.myco.myplugins</groupId>|   <artifactId>myplugin</artifactId>||   <configuration>|     <tomcatLocation>${tomcatPath}</tomcatLocation>|   </configuration>| </plugin>| ...|| NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to|       anything, you could just leave off the <value/> inside the activation-property.|<profile><id>env-dev</id><activation><property><name>target-env</name><value>dev</value></property></activation><properties><tomcatPath>/path/to/tomcat/instance</tomcatPath></properties></profile>--></profiles><!-- activeProfiles| List of profiles that are active for all builds.|<activeProfiles><activeProfile>alwaysActiveProfile</activeProfile><activeProfile>anotherAlwaysActiveProfile</activeProfile></activeProfiles>-->
</settings>

在这里插入图片描述
这样就创建成功了!

🌼3.2使用网页创建

我们不仅可以采用idea创建spring boot项目,还可以采用网页创建
在浏览器搜索页面写入start.spring.io
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
创建成功了,然后在idea打开就好了
创建好之后要删除无用目录
在这里插入图片描述

🐶4.Spring Boot目录工程介绍

在这里插入图片描述
快速添加依赖的办法
使用edit starter插件
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
然后点击要添加的依赖,点击add即可添加依赖

🐶5.使用Spring Boot写一个最简单的程序

package com.example.demo;import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/user")
public class UserController {@RequestMapping("/sayhi")public String sayHi(){return "Hi,Spring Boot.";}
}

点击运行

在这里插入图片描述
在这里插入图片描述
Spring Boot设计思想是约定⼤于配置,类上标注
@SpringBootApplication 就可以启动 Spring Boot 项⽬

(下期解释约定大于配置👀)

🐶6.Spring Boot和Spring做对比

Spring Boot是基于Spring框架的一个轻量级开发框架,目的是让开发Spring应用变得更加简单快捷。Spring是一个完整的框架,包含了多个模块,如Spring MVC、Spring Security等,提供了广泛的功能支持。

Spring BootSpring
开发难度Spring Boot简化了Spring应用的开发,不需要配置大量的XML文件,可以使用注解和自动配置。Spring需要使用XML和注解配置,需要更多的配置和代码编写。
项目依赖Spring Boot提供了一个项目启动器(edit starter),包含了应用开发所需的常用依赖,可以快速构建应用Spring需要手动配置依赖,需要更多的时间和精力。
应用测试Spring Boot支持嵌入式服务器,可以很方便地进行应用测试Spring需要手动启动服务器进行测试,比较复杂。
性能Spring Boot在性能方面与Spring的表现相似,但Spring Boot可以更快地构建和运行应用。和Spring Boot 类似
适用场景Spring Boot适合快速构建小型项目和原型应用Spring适合大型项目和需要更多功能支持的应用。

关于Spring Boot项目的创建和使用我们今天就讲解到这里,我们下期将继续深入学习它的其他知识,下期见咯😘
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/14429.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

VS创建wsdl服务提供给java调用

文章目录 前言1.c#创建asp.net web服务1.1 创建ASP.NET Web应用程序1.2 添加服务类1.3 定义服务方法1.3 浏览服务1.4 发布服务1.5 IIS部署服务 2.Java中调用服务2.1 用动态客户端工厂类调用2.1.1 引入依赖2.1.2 调用测试代码2.1.3 测试结果 2.2 创建代理类进行调用2.2.1 使用ws…

vue3 如何获取env

标题import.meta.env是一个全局属性&#xff0c;它包含了许多有用的环境信息&#xff0c;比如MODE、BASE_URL等。你可以在任何Vue组件、模块或文件中使用它来获取这些环境变量。 console.log(import.meta.env.MODE); // 获取当前模式&#xff0c;比如 development 或 producti…

解决Oracle锁表问题

问题描述&#xff1a; 数据表不能修改或删除数据&#xff0c;如果操作则会卡住&#xff0c;这可能是锁表了。 解决步骤&#xff1a; &#xff08;1&#xff09;查看哪个表被锁 select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked_object a,dba_object…

修改整数(有点坑,所以发出来了)

问题描述 小贝给了小聪一个正整数 x&#xff0c;但是小聪决定把这个数改掉。她可以把整数 x 每个位置上的数 t 改成 9-t。 请你帮助小聪来计算一下&#xff0c;如何把 x 改成一个最小的正整数&#xff0c;注意&#xff0c;不能出现首位为 0 的情况。 输入格式 输入一个正整数…

云原生环境下的安全风险与安全架构设计

随着云计算和容器技术的发展&#xff0c;云原生应用已经成为企业和开发者的新选择。然而&#xff0c;云原生环境也给企业带来了一系列安全挑战。本文将分析云原生环境下的安全风险&#xff0c;并提出相应的安全架构设计策略。 一、云原生环境下的安全风险 云原生环境具有动态性…

git:按照标签查询提交记录log日志

git log 可以查询提交历史&#xff0c;增加一些参数就可以对提交记录log日志进行过滤 # 查询标签v1.0.0之前提交的历史记录 git log v1.0.0 --prettyformat:"%s"# 查询标签v1.0.0之后提交的历史记录 git log v1.0.0.. --prettyformat:"%s"--prettyformat:…

ChatGLM-6B 部署与 P-Tuning 微调实战-使用Pycharm实战

国产大模型ChatGLM-6B微调部署入门-使用Pycharm实战 1.ChatGLM模型介绍 ChatGLM-6B 是一个开源的、支持中英双语的对话语言模型&#xff0c;基于 General Language Model (GLM) 架构&#xff0c;具有 62 亿参数。结合模型量化技术&#xff0c;用户可以在消费级的显卡上进行本…

《吐血整理》进阶系列教程-拿捏Fiddler抓包教程(14)-Fiddler断点(breakpoints)实战,篡改或伪造数据

1.简介 上一篇主要就讲解和分享Fiddler断点的理论和操作&#xff0c;今天宏哥就用具体例子&#xff0c;将上一篇中的理论知识实践一下。而且在实际测试过程中&#xff0c;有时候需要修改请求或响应数据&#xff0c;或者直接模拟服务器响应&#xff0c;此时可以使用fiddler进行…

js的sendBeacon方法介绍

js的sendBeacon方法介绍 Beacon API是一种轻量级且有效的将网页活动记录到服务器的方法。它是一个 JavaScript API&#xff0c;可帮助开发人员将少量数据&#xff08;例如分析或跟踪信息、调试或诊断数据&#xff09;从浏览器发送到服务器。 在本文中&#xff0c;我们将介绍B…

容斥原理 训练笔记

​ 容斥原理 设S是一个有限集&#xff0c;A_1,A_2…A_n是S的n个子集&#xff0c;则 ∣ S − ⋃ i 1 n A i ∣ ∑ i 0 n ( − 1 ) i ∑ 1 ≤ j 1 < j 2 . . . < j i ≤ n ∣ ⋂ k 1 i A j k ∣ |S-\bigcup_{i1}^{n}A_i|\sum_{i0}^{n}(-1)^i\sum_{1\leq j_1< j_2.…

基于长短期神经网络LSTM的位移监测,基于长短期神经网络的位移预测,LSTM的详细原理

目录 背影 摘要 LSTM的基本定义 LSTM实现的步骤 基于长短期神经网络LSTM的位移监测 完整代码: https://download.csdn.net/download/abc991835105/88098131 效果图 结果分析 展望 参考论文 背影 路径追踪预测,对实现自动飞行驾驶拥有重要意义,长短期神经网络是一种改进党的…

有效三角形的个数

给定一个包含非负整数的数组 nums &#xff0c;返回其中可以组成三角形三条边的三元组个数。 示例 1: 输入: nums [2,2,3,4] 输出: 3 解释:有效的组合是: 2,3,4 (使用第一个 2) 2,3,4 (使用第二个 2) 2,2,3 示例 2: 输入: nums [4,2,3,4] 输出: 4 代码如下&#xff1a;…

力扣75——队列

总结leetcode75中队列的算法题解题思路。 上一篇&#xff1a;力扣75——哈希表/哈希集合 以下代码大部分为本人所写&#xff0c;少部分为官方示例代码。 力扣75——队列 1 最近的请求次数2 Dota2 参议院1-2 解题总结 1 最近的请求次数 题目&#xff1a; 写一个 RecentCounter…

okvis

论文 Keyframe-Based Visual-Inertial SLAM Using Nonlinear Optimization 摘要 由于两种感知模式的互补性&#xff0c;视觉和惯性线索的融合在机器人中变得很流行。虽然迄今为止大多数融合策略都依赖于过滤方案&#xff0c;但视觉机器人界最近转向了非线性优化方法&#x…

【React Native】学习记录(二)——路由搭建和常见的开发技巧

模拟器设置成中文 在开发过程中发现&#xff0c;两个模拟器都不能输入中文&#xff0c;所以需要配置一下。 先说一下安卓&#xff0c;在弹出的输入框中查看设置&#xff0c;设置一下对应的languages即可&#xff1a; 在苹果模拟器中&#xff0c;跟苹果手机一样&#xff0c;打…

树莓派本地快速搭建web服务器,并发布公网访问

文章目录 树莓派本地快速搭建web服务器&#xff0c;并发布公网访问 树莓派本地快速搭建web服务器&#xff0c;并发布公网访问 随着科技的发展&#xff0c;电子工业也在不断进步&#xff0c;我们身边的电子设备也在朝着小型化和多功能化演进&#xff0c;以往体积庞大的电脑也在…

Selenium多浏览器处理

Python 版本 #导入依赖 import os from selenium import webdriverdef test_browser():#使用os模块的getenv方法来获取声明环境变量browserbrowser os.getenv("browser").lower()#判断browser的值if browser "headless":driver webdriver.PhantomJS()e…

为Android构建现代应用——应用架构

选择风格(Choosing a style) 我们将依照Google在《应用架构指南》中推荐的最佳实践和架构指南来构建OrderNow的架构。 这些定义包括通过各层定义组件的一些Clean Architecture原则。 层次的定义(Definition of the layers) 在应用程序中&#xff0c;我们将定义以下主要层次…

小程序创建

1&#xff0c;下载HBuilder X ;(3.8.7) HBuilderX-高效极客技巧 2,下载模板&#xff08;不选云服务的&#xff09;&#xff1b; 3&#xff0c;运行-运行到小程序模拟器&#xff1b; 4&#xff0c;安装小程序开发工具&#xff1b; 5&#xff0c;选择稳定版-windows64版&…

SpringBoot 统⼀功能处理

目录 前言 1.⽤户登录权限效验 1.1、最初⽤户登录效验 1.2、Spring AOP ⽤户统⼀登录验证的问题 1.3、Spring 拦截器 了解 创建一个 Spring 拦截器 的流程 1、 创建自定义拦截器&#xff0c;实现 HandlerInterceptor 接⼝的preHandle&#xff08;执⾏具体⽅法之前的预处理…