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>
    

      启动类为如下图所示:

  • 相关阅读:
    spring aop实现数据库的读写分离
    MySQL主从复制(Master-Slave)实践
    java 注解 Annontation
    java NIO介绍
    为什么你学不会递归?告别递归,谈谈我的一些经验(转)
    maven的安装、路径配置、修改库文件路径和eclipse中的配置、创建maven工程(转)
    Eclipse中创建Maven多模块工程
    Eclipse的Working Set管理项目
    Java使用POI读取和写入Excel指南(转)
    Webpack安装和命令
  • 原文地址:https://www.cnblogs.com/yuby/p/13155111.html
Copyright © 2011-2022 走看看