zoukankan      html  css  js  c++  java
  • springboot学习1

    1、idea新建项目

    File ->new ->project 然后选择sring Initializr ,接着next,接着修改相关信息,然后不选择任何依赖,直接next,接着修改项目名字,选择项目路径,点击finish,项目就建好了

     

     2、相关准备:

      项目建立好之后pom文件中可能会出现如下问题:2.3.1.RELEASE是红色的,这是应为刚才第三步的springboot版本过高,可以选择一个低版本的,我这里选择的是2.1.7,1.5.9在我的本地也是可用的,

    改完之后,界面右上角会有一个小弹框,点击Import Changes ,等完毕后就可以启动程序了。

    此时,我这里继续报错:Error:(3, 29) java: 程序包org.junit.jupiter.api不存在 ,此时只需要在pom文件中添加相关jar包的依赖,然后下载相关jar就行,可以在如下网站搜索

    https://mvnrepository.com/缺失的jar包的依赖,然后添加到pom文件,点击import changes下载jar包,

    <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.7.0-M1</version>
        <scope>test</scope>
    </dependency>

     如果还是不行就加入阿里远程仓库配置试一下,我本地通过加上这个就好了,加载pom文件最下main

    <repositories>
            <repository>
                <id>alimaven</id>
                <name>aliyun maven</name>
                <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </repository>
        </repositories>

    启动的时候如果报错:No active profile set, falling back to default profiles: default,需要修改如下依赖,然后下载jar包启动springboot项目就行

    	<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter</artifactId>
    		</dependency>
    改为
    	<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-web</artifactId>
    		</dependency>
    

      启动类为如下图所示:

  • 相关阅读:
    Notepad++ 配置python快捷键运行方法
    Python 安装setuptools方法
    Python 安装selenium方法
    Sublime 的汉化以及原因
    PHP书籍推荐
    PHP 语言结构(Language constructs)和函数的区别 (转)
    程序员问答网站:StackOverflow
    安装SQL SEVER 2005中的两个常见问题
    致IT同仁 —— IT人士常犯的17个职场错误
    PHP书写规范 PHP Coding Standard
  • 原文地址:https://www.cnblogs.com/yuby/p/13155111.html
Copyright © 2011-2022 走看看