网页 综合 更新时间 2026-11-13 15:37:03

https://spring.io/quickstart/

自动蜘蛛 spring.io 正文约 4218 字
An Integrated Developer Environment (IDE) Popular choices include IntelliJ IDEA, Visual Studio Code with Spring Boot Extension Pack, or Eclipse with Spring Tools, and many more.
A Java™ Development Kit (JDK) We recommend BellSoft Liberica JDK version 17, 21, or 25.
Use start.spring.io to create a “web” project. This link opens it with the settings below already filled in:
Hit the “Generate” button, download the zip, and unpack it into a folder on your computer.
Projects created by start.spring.io contain Spring Boot , a framework that makes Spring ready to work inside your app, but without much code or configuration required. Spring Boot is the quickest and most popular way to start Spring projects.
Open up the project in your IDE and select the tab matching your project's language below. Locate the application file at the indicated path and replace its contents with the code shown. You can copy and paste the code or just type it.
src/main/java/com/example/demo/DemoApplication.java
src/main/kotlin/com/example/demo/DemoApplication.kt
This is all the code required to create a simple “Hello World” web service in Spring Boot.
The hello() method we’ve added takes a String parameter called name and uses it to create a greeting. This means that if you set your name to "Amy" in the request, the response would be “Hello Amy!”.
The @RestController annotation tells Spring that this code describes an endpoint that should be made available over the web. The @GetMapping("/hello") tells Spring to use our hello() method to answer requests that get sent to the http://localhost:8080/hello address. Finally, @RequestParam binds the name request parameter to the method’s name parameter. If it’s not there, the Java example uses the annotation’s defaultValue, and the Kotlin example uses a default argument, both set to "World".
Let’s build and run the program. Open a command line (or terminal) and navigate to the folder where you have the project files. We can build and run the application by issuing the following command:
If you chose Maven, run ./mvnw spring-boot:run (MacOS/Linux) or .\mvnw.cmd spring-boot:run (Windows) instead.
You should see some output where the last two lines look similar to this:
This tells us that Spring has started. Spring Boot’s embedded Apache Tomcat server is acting as a webserver and is listening for requests on localhost port 8080. Open your browser and in the address bar at the top enter http://localhost:8080/hello, or use curl in another terminal:
You should get a nice friendly response like this:
What should happen if you add ?name=Amy to the end of the URL?
You've already seen how simple Spring can be, but it's also very flexible. There are thousands of things you can do with Spring, and we have lots of guides available to take you through the most popular choices. Why not keep on learning and try one of these additional guides?
VMware offers training and certification to turbo-charge your progress.
TrueSource Spring Enterprise offers support and binaries for OpenJDK™, Spring, and Apache Tomcat® in one simple subscription.
Check out all the upcoming events in the Spring community.
Stay connected with the Spring newsletter
Copyright © 2005 - 2026 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. Terms of Use • Privacy • Trademark Guidelines
Apache®, Apache Tomcat®, Apache Kafka®, Apache Cassandra™, and Apache Geode™ are trademarks or registered trademarks of the Apache Software Foundation in the United States and/or other countries. Java™, Java™ SE, Java™ EE, and OpenJDK™ are trademarks of Oracle and/or its affiliates. Kubernetes® is a registered trademark of the Linux Foundation in the United States and other countries. Linux® is the registered trademark of Linus Torvalds in the United States and other countries. Windows® and Microsoft® Azure are registered trademarks of Microsoft Corporation. “AWS” and “Amazon Web Services” are trademarks or registered trademarks of Amazon.com Inc. or its affiliates. All other trademarks and copyrights are property of their respective owners and are only mentioned for informative purposes. Other names may be trademarks of their respective owners.
访问原文 返回搜索 https://spring.io/quickstart
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。