springboot之项目搭建并say hi

news2024/9/29 22:49:34

写在前面

本文看下如何搭建一个最简单的支持http接口的hello程序。

1:正文

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
接着引入springboot依赖:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.12</version>
    <relativePath/>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

定义main函数:

package com.dahuyou;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController()
public class MyApp {
    public static void main(String[] args) {
        SpringApplication.run(MyApp.class);
    }

    @RequestMapping("/res")
    public String res() {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "{\"code\":200,\"msg\":\"短信申请发送成功!\",\"smsContent\":\"一口吃的监考老师,发现一个学生在作弊,便气急败坏地指着那学生吼道:“你…你…你…你…你竟敢作弊,站起来! 话刚说完,有5名学生站了起来。!\",\"reqSerialNo\":\"192929229\",\"smsId\":1414615,\"remitLinkId\":20}";
    }
}

这就done了,访问一下:
在这里插入图片描述

附setting配置:

<?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 at

    http://www.apache.org/licenses/LICENSE-2.0

Unless 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.home}/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: ~/.m2/repository
  
  -->
<localRepository>D:/mvn_rep/mvn_rep_361</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>
    -->
  <pluginGroup>org.apache.tomcat.maven</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>
    
    <server>
    <id>jinher-snapshots</id>
    <username>admin</username>
    <password>admin123</password>
    </server>
    <server>
    <id>jiher</id>
    <username>admin</username>
    <password>admin123</password>
    </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.
   |-->

    <!-- 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.
     |  -->
    
  <!-- 
  <mirrors>  
    <mirror>  
      <id>nexus-aliyun</id>  
      <mirrorOf>central</mirrorOf>    
      <name>Nexus aliyun</name>  
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>  
    </mirror>
  </mirrors>
  -->
  <profiles>  
  <!--
  <profiles>  
    <profile>  
      <id>dev</id>  
      <repositories>  
        <repository>  
          <id>public</id>  
          <url>http://192.168.1.5:8081/nexus/content/groups/public/</url>  
          <releases>  
            <enabled>true</enabled>  
          </releases>  
          <snapshots>  
            <enabled>true</enabled>  
          </snapshots>  
        </repository>  
      </repositories>  
    </profile>
    <profile>  
      <id>central</id>  
      <repositories>  
        <repository>  
          <id>central</id>  
          <url>http://192.168.1.5:8081/nexus/content/repositories/central/</url>  
          <releases>  
            <enabled>true</enabled>  
          </releases>  
          <snapshots>  
            <enabled>true</enabled>  
          </snapshots>  
        </repository>  
      </repositories>  
    </profile> -->

    <profile>  
      <id>aliyun</id>  
      <repositories>  
        <repository>  
          <id>aliyun</id>  
          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
          <releases>  
            <enabled>true</enabled>  
          </releases>  
          <snapshots>  
            <enabled>true</enabled>  
          </snapshots>  
        </repository>  
      </repositories>  
    </profile>
    
    <profile>
      <id>jdk18</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
      </properties>    
    </profile>
  </profiles>  
  <activeProfiles>  
    <!--<activeProfile>dev</activeProfile>
    <activeProfile>central</activeProfile>-->
    <activeProfile>aliyun</activeProfile>
  </activeProfiles>
  <!-- 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.
   |
   |-->
  
    <!-- 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>

    --> 
  
 

  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
</settings>

写在后面

参考文章列表

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

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

相关文章

4.7重复的子字符串(LC_459-E)

给定一个非空的字符串 s &#xff0c;检查是否可以通过由它的一个子串重复多次构成。 示例 1: 输入: s "abab" 输出: true 解释: 可由子串 "ab" 重复两次构成。示例 2: 输入: s "aba" 输出: false示例 3: 输入: s "abcabcabcabc"…

无线终端ZWS云应用(一)—1分钟快速接入CATCOM-100 DTU上云

环境监测设备&#xff08;如温湿度传感器&#xff09;可以通过DTU终端CATCOM-100接入ZWS云平台&#xff0c;实现远程监控和管理。 准备工作 准备一个温湿度传感器和一个致远电子的DTU终端CATCOM-100。准备一张SIM卡&#xff0c;用于4G联网。 操作步骤 1. 云平台设备创建 1.1 …

PCIe563XD系列多功能异步数据采集卡64路AD信号采集500K采样频率

阿尔泰科技 型号&#xff1a;PCIe5630D/5631D/5632D/5633Dhttps://item.taobao.com/item.htm?spma1z10.3-c-s.w4002-265216876.12.84513350msbilC&id589158158140&piskf6qstfsYFCA6dK09z-BERdlfDjobG5szWKMYE-KwHcntcqeoOlla3juYGWce0OmNomNjOScZ7chwcmwbiSuY0jrXIkN…

nodejs发送邮件给多个收件人如何实现群发?

node.js发送邮件的方法&#xff1f;如何用nodejs自动发送邮件&#xff1f; Node.js发送邮件是一种高效而灵活的解决方案&#xff0c;尤其是在需要群发邮件时。AokSend将探讨如何使用Node.js发送邮件给多个收件人&#xff0c;帮您实现邮件的批量发送。 nodejs发送邮件&#xf…

2024年3款精选工具+谷歌翻译:发现那些你不知道的高级功能!

现在这世界变得越来越像一个村了&#xff0c;语言不应该是我们聊天的绊脚石。但是在工作的时候&#xff0c;碰到不同语言的文件、邮件和会议&#xff0c;翻译还是挺考验人的。好在有谷歌翻译这个牛气的工具&#xff0c;还有其他几个好用的软件帮忙&#xff0c;让我们在工作上翻…

前端常见**MS题 [3]

css部分 1、简单说明一下盒模型 CSS盒模型定义了盒的每个部分包含&#xff1a; margin, border, padding, content 。根据盒子大小的计算方式不同盒模型分成了两种&#xff0c;标准盒模型和怪异盒模型。 标准模型&#xff0c;给盒设置 width 和 height&#xff0c;实际设置的是…

【吊打面试官系列-Memcached面试题】memcached 的多线程是什么?如何使用它们?

大家好&#xff0c;我是锋哥。今天分享关于 【memcached 的多线程是什么&#xff1f;如何使用它们&#xff1f; 】面试题&#xff0c;希望对大家有帮助&#xff1b; memcached 的多线程是什么&#xff1f;如何使用它们&#xff1f; 线程就是定律&#xff08;threads rule&#…

linux 第一个命令的编写

1. 命令的概念 命令就是可执行程序。 比如说输入“ls -al”命令&#xff0c;ls 就是可执行程序的的名字。-al 就是要传递进去的参数。 ps 命令&#xff1a; 功能&#xff1a;显示进程的动态。 输入 ps 命令 当 shell 接收到命令以后&#xff0c;会根据输入的字符到环境变量和默…

UDP/TCP --- Socket编程

本篇将使用 Linux 中的系统调用来实现模拟 TCP 和 UDP 的通信过程&#xff0c;其中只对 UDP 和 TCP 进行了简单的介绍&#xff0c;本篇主要实现的是代码&#xff0c;至于 UDP 和 TCP 的详细讲解将会在之后的文章中给出。 本篇给出的 tcp 和 udp 的代码中的 echo 都是测试连接是…

电脑死机之后强制关机重启,只能进入到Bios,不能进入到系统?

前言 最近遇到好几件比较有意思的事情&#xff0c;粉丝过来求助咨询&#xff1a;电脑不知怎的就黑屏死机了&#xff0c;重启之后&#xff0c;电脑只能进入到Bios&#xff0c;无论怎么重启都没用。 把电脑拆出来看了看&#xff0c;线路一切正常。感觉上可能是内存条的问题&…

NRK3301语音识别芯片在汽车内饰氛围灯上的应用方案解析

随着智能汽车的快速发展&#xff0c;车载语音交互技术逐渐成为提升驾驶体验的关键技术之一。传统的汽车内饰氛围灯语音识别系统往往依赖于手动操作&#xff0c;不仅操作繁琐&#xff0c;而且在驾驶过程中容易分散驾驶员的注意力。因此&#xff0c;开发一种高效、便捷的汽车内饰…

OpenAI gym: when is reset required?

题意&#xff1a;“OpenAI Gym: 什么时候需要重置&#xff1f;” 问题背景&#xff1a; Although I can manage to get the examples and my own code to run, I am more curious about the real semantics / expectations behind OpenAI gym API, in particular Env.reset() …

基于网格尺度的上海市人口分布空间聚集特征分析与冷热点识别

在上篇文章提到了同一研究空间在不同尺度下的观察可能会带来不同的见解和发现&#xff0c;这次我们把尺度缩放到网格&#xff0c;来看网格尺度下的空间自相关性、高/低聚类&#xff0c;这些&#xff0c;因为尺度缩放到网格尺度了&#xff0c;全国这个行政区范围就显的太大了&am…

Python采集网页数据:八招全解

在信息时代&#xff0c;海量的数据日益成为企业和个人获取商业价值的重要手段。而获取这些数据的方式之一就是通过网络爬虫技术采集网络上的各种信息&#xff0c;对于 Python 程序员来说&#xff0c;这项工作并不困难。本文将从八个方面&#xff0c;带你了解如何使用 Python 采…

查找技术与平衡查找树

目录 引言 查找技术的重要性 顺序查找 顺序查找的优缺点对比 二分查找 二分查找的步骤总结 哈希查找 哈希函数设计与冲突解决 平衡查找树 二叉搜索树、AVL树与红黑树 平衡查找树的插入与删除操作 平衡查找树的应用场景 总结与应用 综合实例分析 引言 查找是计算机…

算法训练营三刷(Java) | 第六天~第十一天

算法训练营三刷&#xff08;Java&#xff09; | 第六天~第十一天 第六天 LeetCode 242 有效的字母异位词 解题思路&#xff1a; 数组哈希记录每个字幕出现的次数&#xff0c;然后进行比较。Java中字符串取下标i处字符可以使用charAt成员函数也可以转化为字符数组之后用数组的…

三菱PLC数据 转IEC61850项目案例

目录 1 案例说明 2 VFBOX网关工作原理 3 准备工作 4 网关采集三菱PLC数据 5 用IEC61850协议转发数据 6 网关使用多个逻辑设备和逻辑节点的方法 7 其他说明 8 案例总结 1 案例说明 设置vfbox网关采集三菱PLC数据把采集的数据转成IEC61850协议转发给其他系统。 2 VFBOX网关工…

【Python大语言模型系列】如何在LangChain中使用ReAct构建AI Agent(案例+源码)

一、引言 当前&#xff0c;在各个大厂纷纷卷LLM的情况下&#xff0c;各自都借助自己的LLM推出了自己的AI Agent&#xff0c;比如字节的Coze&#xff0c;百度的千帆等&#xff0c;还有开源的Dify。你是否想知道其中的原理&#xff1f;是否想过自己如何实现一套AI Agent&#xff…

联想凌拓发布多款新一代AI数据管理解决方案

联想凌拓发布多款新一代AI数据管理解决方案 联想凌拓正式宣布推出 NetApp AFF C 系列、 NetApp ASA A 系列、 NetApp ASA C 系列、Lenovo ThinkSystem DG系列、Lenovo ThinkSystem DM3010H企业级存储阵列及MagnaScale数据管理平台V4.0全面升级&#xff0c;让企业应用更简便、更…

华为数通方向HCIP-DataCom H12-821题库(更新单选真题:21-30)

第21题 以下关于0SPF中ABR的描述,错误的是哪一项? A、ABR将连接的非骨干区域内的1类和2类1SA转换成3类LSA,发布到骨干区域中 B、ABR不能够产生4类和5类LSA C、ABR上有多个LSDB,ABR为每一个区域维护一个LSDB D、ABR将骨干区域内的1类、2类LSA和3类LSA转换成三类LSA,发布到…