【Spring boot】快速创建springboot项目

 1、文件-新建项目

 

2、选择spring 填写信息

 

3、添加依赖包 <后续可以在pom.xml中引入依赖包>

 

 

4、项目生成完成

 

5、配置端口号

server.port=8080

 

 

6、编写controller 验证项目

package com.project.one.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class oneController {

    @RequestMapping("/one")
    @ResponseBody
    public String one(){
        return "Hello World";
    }
}

运行成功

 

浏览器访问:http://localhost:8080/one

  

 

 

 

Spring boot 版本 :v2.0.5.RELEASE

JDK版本:1.8

maven版本:3.3.9

 

maven 的依赖网址:https://mvnrepository.com/ 

 


 

运行问题1:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:testCompile (default-testCompile) on project demo-first: Fatal error compiling

  

解决方案: 

  1、查看设置中java编译器java版本

    

   2、项目结构中模块及sdk的java版本  

    

      

  3、pom.xml中的java版本  

    

 

运行问题2:程序包org.junit.jupiter.api不存在

解决方案:

  1、pom.xml 添加junit依赖 <parent对应的2.2以上>

  <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.5.0</version>
            <scope>test</scope>
        </dependency>

 

运行问题3:No MyBatis mapper was found in '[com.project]' package. Please check your configuration.

 解决方案:

 mybatis引起的 <注销依赖重新刷新maven后及没有此警告>

        <!-- mybatis -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.2</version>
        </dependency>

  

 

posted @ 2023-08-18 09:47  Phoenixy  阅读(49)  评论(0编辑  收藏  举报