# Spring Boot REST API tutorial, part 1: Create and run a project

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/help/idea/2026.3/llms.txt).

* [1: Create and run a Spring Boot project]()

* [2: Add REST endpoints](spring-boot-tutorial-rest-endpoints.html)

* [3: Upload and download files](spring-boot-tutorial-file-upload-download.html)

* [4: Store data in H2 and package a JAR](spring-boot-tutorial-h2-database-jar.html)

In the first part of this tutorial, generate a Spring Boot project, arrange its packages, and add a controller that responds to a browser request.

Procedure: Create a project with Spring Initializr

Spring projects are generated by [Spring Initializr](https://start.spring.io/). You can use the website, but IntelliJ IDEA has the same generator built into the New Project wizard, which saves downloading and unpacking an archive.

1. On the Home screen, click New Project. If another project is already open, go to `File | New | Project` in the main menu.

2. Select Spring Boot from the Generators list.

3. Name the project `photos-demo` and select Java as the Language.

4. Select Maven as the Type.

Maven and Gradle both work. If you already use one of them, keep to it. If you are choosing for the first time, Maven has less to learn before the project builds, and this tutorial uses it.

5. Fill in the coordinates that identify the project.

Group names the organization that owns the code, normally written as a domain name in reverse. This tutorial uses `com.jetbrains`; in your own projects, use your company or personal domain.

Artifact identifies this one project inside that group. Enter `photos-demo`. Together with the group, it is what a build tool resolves when another project depends on yours.

Package name is the root package for your Java sources, and IntelliJ IDEA builds a suggestion from the two fields above. Set it to `com.jetbrains.photos.demo`. Every class you write in this tutorial goes into this package or below it, which matters later: Spring scans the package holding the application class and its subpackages, and finds nothing outside it.

6. Select a JDK from the JDK list, then select the same version from the Java list. Unless you have a reason to stay on an older release, use the latest one available.

If a JDK is installed but IntelliJ IDEA does not list it, select Add JDK and point to its home directory. If none is installed, select Download JDK.

7. Leave Jar selected as the packaging type and leave the remaining fields at their defaults. Click Next.

Select these dependencies:

* Spring Web: HTTP request handling, JSON conversion, and an embedded web server.

* Spring Data JDBC: maps Java objects to database rows in the final part.

* H2 Database: a database that runs with the application without a separate installation.

Click Create and wait for IntelliJ IDEA to generate and import the project.

Procedure: Set up the package structure

The generated project contains `pom.xml` for Maven dependencies, `src/main/java` for Java code, and `src/main/resources` for `application.properties` and static files.

The generator puts the application class in one package. Before adding more classes, create subpackages for their different responsibilities so that each new class has a place in the project.

* In the [Project](project-tool-window.html) tool window, right-click the package containing your application class (in this tutorial, it is `com.jetbrains.photos.demo`) and select `New | Package`.

Create three subpackages:

* `web`: controllers that handle HTTP requests.

* `service`: application logic and photo storage.

* `model`: classes that represent photo data.

![Project tool window with the model, service, and web subpackages under com.jetbrains.photos.demo next to the PhotosDemoApplication class.](https://resources.jetbrains.com/help/img/idea/2026.3/sb_packages.png)

Keep `PhotosDemoApplication` in the root package. Spring scans that package and its subpackages to find the controllers and services you add.

Procedure: Create a REST controller

A REST controller connects an incoming HTTP request to a Java method. Start with a method that returns a greeting: seeing it in the browser confirms that requests reach your code before you add the photo API.

1. Right-click the `web` package and select `New | Java Class`. Name the class `PhotosController`.

2. Add the greeting method and annotations shown below. As you type `@RestController` and `@GetMapping`, accept them from the completion list to add their imports. Press `Ctrl+Space` (Windows), `⌃ Space` (macOS), `⌃ Space` (IntelliJ IDEA Classic (macOS)), `⌃ Space` (macOS System Shortcuts), `Ctrl+Space` (XWin), `Ctrl+Space` (GNOME), `Ctrl+Space` (KDE), `Alt+/` (Emacs), `Ctrl+Space` (Sublime Text), `⌃ Space` (Sublime Text (macOS)), `Ctrl+Space` (Visual Studio), `⌃ Space` (Visual Studio (macOS)), `Ctrl+Space` (NetBeans), `Ctrl+Space` (Eclipse), `⌃ Space` (Eclipse (macOS)) if the list does not appear.

```JAVA
@RestController
public class PhotosController {

    @GetMapping("/")
    public String hello() {
        return "Hello World";
    }

}
```

The two annotations divide the work. `@RestController` tells Spring that this class handles requests, so Spring creates an instance at startup. `@GetMapping("/")` maps GET requests for `/` to `hello()`. The returned string becomes the response body that the browser displays.

> **Tip:**
> To read the Javadoc for an annotation without leaving the editor, hover over it or use the [Documentation](documentation-tool-window.html) tool window.

Procedure: Run the Spring Boot application

1. Open `PhotosDemoApplication` and click ![the Run button](https://resources.jetbrains.com/help/img/idea/2026.3/app-client.expui.gutter.run.svg) Run in the gutter next to `main()`, or press `Shift+F10` (Windows), `⌃ R` (macOS), `⇧ F10` (IntelliJ IDEA Classic (macOS)), `⌥ ⇧ R` (macOS System Shortcuts), `Shift+F10` (XWin), `Shift+F10` (GNOME), `Shift+F10` (KDE), `Shift+F10` (Emacs), `Shift+F10` (Sublime Text), `Shift+F10` (Sublime Text (macOS)), `Ctrl+F5` (Visual Studio), `⌃ F5` (Visual Studio (macOS)), `F6` (NetBeans), `Alt+Shift+X` (Eclipse), `⌘ ⇧ F11` (Eclipse (macOS)).

2. In the [Run](run-tool-window.html) tool window, look for the message that Tomcat started on port 8080.

![Run tool window for PhotosDemoApplication with the console log confirming that Tomcat is initialized and started on port 8080.](https://resources.jetbrains.com/help/img/idea/2026.3/sb_tomcat_8080.png)

Open `http://localhost:8080/` in your browser. The page displays `Hello World`.

[Next part](spring-boot-tutorial-rest-endpoints.html)

