English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The following are the steps to create a simple Spring Boot project.
Step1: Open Spring initializr https://start.spring.io .
Step2: provided groupand artifactname. We provide the group name com.w3codebox and the artifact spring-boot-example .
Step3: Now, click Generate (Generate).
When we click the 'Generate' button, it will start packaging the project as .rar the file and download the project.
Step4: Extract RAR File.
Step5: ImportFolder.
File->Import->Existing Maven Project->Next->Browse->Select Project->Complete
Importing this project may take some time. After successfully importing the project, we can Package Explorer To view the project directory, see the following figure:
SpringBootExampleApplication .java
package com.w3codebox.springbootexample; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class SpringBootExampleApplication { public static void main(String[] args) { SpringApplication.run(SpringBootExampleApplication.class, args); } }
pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/boot-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent/plugin <version>2.2.2.BUILD-SNAPSHOT</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.w3codebox/groupId> <artifactId>spring-boot-example/plugin <version>0.0.1-SNAPSHOT</version> <name>spring-boot-example/name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</plugin </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</plugin <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</plugin </exclusion> </exclusions> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-boot-maven/plugin </artifactId </plugin </plugins build <repositories> <pluginRepository>-<pluginRepositories>/id> milestones/name> <url>https://repo.spring.io/<name>Spring Milestones</name>/url> </<repository> <repositories> <pluginRepository>-<id>spring</id>/id> <name>Spring Snapshots</name>/name> <url>https://repo.spring.io/snapshot/url> <snapshots> <enabled>true</enabled>/enabled> </snapshots> </<repository> </repository repositories milestone <pluginRepository>-<pluginRepositories>/id> milestones/name> <url>https://repo.spring.io/<name>Spring Milestones</name>/url> </pluginRepository> milestone <pluginRepository>-<id>spring</id>/id> <name>Spring Snapshots</name>/name> <url>https://repo.spring.io/snapshot/url> <snapshots> <enabled>true</enabled>/enabled> </snapshots> </pluginRepository> </pluginRepositories> </project>
Step6: : Run SpringBootExampleApplication.java File.
Right-click on this file-> Running Method-> Java Application
The following figure shows that the application has been successfully run.