准备工作:
1、Intellij IDEA (ULTIMATE版):官网下载地址
2、JDK
一、创建新项目
二、左侧面板选择Spring Initializr
输入项目名称,项目组名称和项目ID,点击进入下一步
下面的页面是用于添加依赖的,可以根据需求,添加依赖。或者在pom.xml文件进行添加也可以。主要包括:Core(核心依赖)、SQL、NOSQL
当前测试只需勾选 Web。
点击Next,项目创建结束。项目架构如下所示:(注:Example.java是我添加的)
二、在相应目录下创建 Example.java。代码如下:
package com.example.demo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @EnableAutoConfiguration public class Example { @RequestMapping("/") String home() { return "Hello World!"; } @RequestMapping("/hello/{myName}") String index(@PathVariable String myName) { return "Hello "+myName+"!!!"; } }
三、运行项目,选中 SpringbootTestApplication.java,右击--Run 'SpringbootTestApplication' ,或者点击如图所示按钮:
四、程序成功启动,控制台如下所示(部分):
五、最后我们来测试一下:输入 http://localhost:8080/ 和 http://localhost:8080/hello/王大陆
测试成功!!!
最后,另外附上pom.xml代码,仅供参考。
930406f08da8ee4a2ff134b688d29d1d 261ccf601aed9e706bad7e14d745ea63 f88eb0eb1aecac9ee9b4f14c6ec6df3b4.0.064e738e3986bec0362927b9ad33d6f1a 05a8acc5c31084a4f61ade01873802cacom.example192ca2f7b8c770b01c8f81e6bdd5b947 9bc4cbb67f66e148869423c0d27e5f90springboot_testb68fb17cb904a46b73e6272850323873 3d689bd3819ead35ed794427bd12f4590.0.1-SNAPSHOT83a577b3f930c490b31329be5e672d0b 0d5281799fde01379a2f5b5ea0c57ee5jarb381c39f05d1340a5f54760f38fa259d 8a11bc632ea32a57b3e3693c7987c420springboot_testdf406f776eecbaf16b62325323196f14 8b55addfb40ddf4a384b1010d729e503Demo project for Spring Boota11945cc7b2902590ebb81ca9fd0b283 58652436a08d62d32b90566dafe0913c 05a8acc5c31084a4f61ade01873802caorg.springframework.boot192ca2f7b8c770b01c8f81e6bdd5b947 9bc4cbb67f66e148869423c0d27e5f90spring-boot-starter-parentb68fb17cb904a46b73e6272850323873 3d689bd3819ead35ed794427bd12f4591.5.4.RELEASE83a577b3f930c490b31329be5e672d0b 9d08dd43193b87e544f7f9753dac4bce 8d2d71f76b067132be80f6f649e0b044 db7b8d074c72824ed121864240fe4c81 a01741acb88936e4cea4237317380dd9 1c7a7393b6227ec4d47c36077ff090b8UTF-8e1707586e242e616eb540a7accd7b351 d2d8c130ea6225f24b1c2ce2131af998UTF-837d0ee9d6f821be650562ff4d5ce07f8 cba97bffed69576781755455c6f1e4131.837fea447ce86e32369605f68ca6046c0 86cd8b5c0fbd401fb69261955cf13796 fce2022be5e87c17c94245fd7ccbf1d9 8a6cc4527fc0e71b0dfbcd757b4f1373 b4b38e33757a6497aa8690936b905cc1 05a8acc5c31084a4f61ade01873802caorg.springframework.boot192ca2f7b8c770b01c8f81e6bdd5b947 9bc4cbb67f66e148869423c0d27e5f90spring-boot-starter-webb68fb17cb904a46b73e6272850323873 09a0e22e5aaafd848ae04665be625b91 b4b38e33757a6497aa8690936b905cc1 05a8acc5c31084a4f61ade01873802caorg.springframework.boot192ca2f7b8c770b01c8f81e6bdd5b947 9bc4cbb67f66e148869423c0d27e5f90spring-boot-starter-testb68fb17cb904a46b73e6272850323873 06db57cb000bdd2564c5b32a302b10e2test03b1008234ba0cf6ad3c873aea327e8a 09a0e22e5aaafd848ae04665be625b91 d233ceef72c18d2307de4871b5eff5ad 5ac54a929980b32fdd2e48b6a8da067c c4222ff3007372f15ec728b963e717b6 33ca7039399a4759a8764ea38765dd46 05a8acc5c31084a4f61ade01873802caorg.springframework.boot192ca2f7b8c770b01c8f81e6bdd5b947 9bc4cbb67f66e148869423c0d27e5f90spring-boot-maven-pluginb68fb17cb904a46b73e6272850323873 9424ec9162a9b85f34067d0c54f34b32 f3567a435ac6132b26525998d793443b f82c24fb6fac67972f6e79c18ccef56a 1755c7176d4002e2a322de4f48c796fa
这是第一次接触 SpringBoot架构,恩,先记下来,免得以后忘记了
以上是SpringBoot入门第一章:Hello World的详细内容。更多信息请关注PHP中文网其他相关文章!

JVM'SperformanceIsCompetitiveWithOtherRuntimes,operingabalanceOfspeed,安全性和生产性。1)JVMUSESJITCOMPILATIONFORDYNAMICOPTIMIZAIZATIONS.2)c提供NativePernativePerformanceButlanceButlactsjvm'ssafetyFeatures.3)

JavaachievesPlatFormIndependencEthroughTheJavavIrtualMachine(JVM),允许CodeTorunonAnyPlatFormWithAjvm.1)codeisscompiledIntobytecode,notmachine-specificodificcode.2)bytecodeisisteredbytheybytheybytheybythejvm,enablingcross-platerssectectectectectross-eenablingcrossectectectectectection.2)

TheJVMisanabstractcomputingmachinecrucialforrunningJavaprogramsduetoitsplatform-independentarchitecture.Itincludes:1)ClassLoaderforloadingclasses,2)RuntimeDataAreafordatastorage,3)ExecutionEnginewithInterpreter,JITCompiler,andGarbageCollectorforbytec

JVMhasacloserelationshipwiththeOSasittranslatesJavabytecodeintomachine-specificinstructions,managesmemory,andhandlesgarbagecollection.ThisrelationshipallowsJavatorunonvariousOSenvironments,butitalsopresentschallengeslikedifferentJVMbehaviorsandOS-spe

Java实现“一次编写,到处运行”通过编译成字节码并在Java虚拟机(JVM)上运行。1)编写Java代码并编译成字节码。2)字节码在任何安装了JVM的平台上运行。3)使用Java原生接口(JNI)处理平台特定功能。尽管存在挑战,如JVM一致性和平台特定库的使用,但WORA大大提高了开发效率和部署灵活性。

JavaachievesPlatFormIndependencethroughTheJavavIrtualMachine(JVM),允许Codetorunondifferentoperatingsystemsswithoutmodification.thejvmcompilesjavacodeintoplatform-interploplatform-interpectentbybyteentbytybyteentbybytecode,whatittheninternterninterpretsandectectececutesoneonthepecificos,atrafficteyos,Afferctinginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginginging

JavaispoperfulduetoitsplatFormitiondence,对象与偏见,RichstandardLibrary,PerformanceCapabilities和StrongsecurityFeatures.1)Platform-dimplighandependectionceallowsenceallowsenceallowsenceallowsencationSapplicationStornanyDevicesupportingJava.2)

Java的顶级功能包括:1)面向对象编程,支持多态性,提升代码的灵活性和可维护性;2)异常处理机制,通过try-catch-finally块提高代码的鲁棒性;3)垃圾回收,简化内存管理;4)泛型,增强类型安全性;5)ambda表达式和函数式编程,使代码更简洁和表达性强;6)丰富的标准库,提供优化过的数据结构和算法。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

SublimeText3汉化版
中文版,非常好用

Dreamweaver Mac版
视觉化网页开发工具

SublimeText3 英文版
推荐:为Win版本,支持代码提示!