自学SpringBoot学习笔记--搭建项目

大神请飘过,由于自己健忘厉害,所以将学习过程记录下来~

idea快速创建springboot测试项目:

File-->new project-->SpringInitializr


Next


为项目起好组名,项目名。Next,因为我要创建web项目,故做以下配置。(避免我们还要去pom中去配置)


这里选中一个web就可以了 下面的sql啥的如果需要也是可以选的,但是一旦选择了需要配置数据源,否则启动项目会报错。在这里我选择以后再配置,这里就是快速搭建项目。


项目名字

Finish,项目结构


找到项目的的入口类,PaomoApplication


此注解代表了项目入口。为了便于测试,我要加一个Controller


现在启动项目。


只需要启动PaomoApplication就可以。


默认8080端口,浏览器访问一下。


ojbk,完成。

注:

如果端口被占用了,想修改端口。

在application.properties中修改一下:


POM文件说明:

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>

   <groupId>com.learn</groupId>
   <artifactId>paomo</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>

   <name>paomo</name>
   <description>Demo project for Spring Boot</description>

   <!--SpringBoot起步依赖-->
   <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.2.RELEASE</version>
      <relativePath/> <!-- lookup parent from repository -->
   </parent>

   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
   </properties>

   <!--web项目基础依赖-->
   <dependencies>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
   <!--springboot单元测试依赖-->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-test</artifactId>
         <scope>test</scope>
      </dependency>
   </dependencies>
   <!--maven-->
   <build>
      <plugins>
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
         </plugin>
      </plugins>
   </build>


</project>

猜你喜欢

转载自blog.csdn.net/weixin_38519981/article/details/80607919