So, here is a simple case.
First of all, we need to create a Spring WEB MVC
project. We might as well find out how to start from the official website. First, find the official documents.
You can see Spring
the environmental requirements for creating applications, JDK1.8
& Maven 3.2+
. Then, find the manual creation introduction:
Then, follow the steps above to import it into idea
and idea
configure it in the middle maven
:
specify the maven
file that you installed and configured , and the file location maven
is the conf/settings.xml
file in the installation directory , such as Alibaba Cloud Image address:
<!-- 阿里云仓库 -->
<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>
<profile>
<id>jdk-1.8</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>
Finally, the downloaded sample project was imported and synchronized maven
, but an error occurred: the
Internet says that you need to specify springframework.boot
the version, such as:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.4.4</version>
</plugin>
</plugins>
</build>
Sure enough, the problem of redemption was solved.
Then, according to the document, create the following two files:
Then, Application
start in:
Follow the prompts, the address is: http://localhost:8080/
Then, test according controller
to the address in the configuration http://localhost:8080/greeting?name=User
:
Official case address: https://spring.io/guides/gs/rest-service/
Official document address: https://docs.spring.io/spring-framework/docs/current/reference/html/