当前位置:   article > 正文

springboot+ mybatis项目搭建错误大全_could not find artifact org.mybatis.spring.boot:my

could not find artifact org.mybatis.spring.boot:mybatis-spring-boot-starter:

Cannot instantiate interface org.springframework.context.ApplicationContextInitializer : org.springframework.boot.context.ConfigurationWarningsApplicationContextInitializer

原因

配置pom.xml 把其他的删干净 如 spring
项目中有两个boot的版本,一个高版本一个低版本,导致冲突.

解决方法

查看自己项目中导入的依赖里,是否包含其他版本的boot与自己pom.xml里的boot的版本冲突
最终应该如这般

<?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>org.example</groupId>
    <artifactId>spingboot_demo</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
<!--       配置的 版本要在这里看清楚-->



        <!-- druid连接池版本 -->
        <druid.version>1.1.17</druid.version>
        <!-- alibaba开发的druid连接池 -->

    </properties>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <!--版本无所谓的,想用别的也行
        爆红   版本较高,阿里云仓库没有-->
        <version>2.2.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <!-- 对应properties中的<druid.version> -->
            <version>${druid.version}</version>
        </dependency>
<!--        <dependency>-->
<!--            <groupId>org.springframework</groupId>-->
<!--            <artifactId>spring-beans</artifactId>-->
<!--            <version>5.3.2</version>-->
<!--            <scope>test</scope>-->
<!--        </dependency>-->


    </dependencies>
    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/libs-snapshot</url>
        </repository>
    </repositories>
<!--解决版本爆红问题 因为RELEASE版本是不稳定的,于是需要指定spring的仓库
,在pom.xml后面添加如下代码,然后保存pom.xml文件,就会重新从repo.spring.io中引入jar包-->
    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <url>http://repo.spring.io/libs-snapshot</url>
        </pluginRepository>
    </pluginRepositories>

<!--    构建搭建插件  -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93

数据库和mybatis版本的依赖
在这里插入图片描述
Could not find artifact org.mybatis.spring.boot:mybatis-spring-boot-starter:pom:3.5.6 in aliyun

测试运行失败

在这里插入图片描述
原来还要在测试类里制定启动类。。。解决办法很简单,把@SpringBootTest()注解改成@SpringBootTest(classes = App.class)就可以了。就像这样:
注:我这里的启动类名为App,更改的时候根据自己启动类名来改

springboot 项目无法启动

在这里插入图片描述

Failed to retrieve application JMX service URL
在 edit configurations 取消勾选 Enable JMX Agent
在这里插入图片描述

测试运行还是失败 测试类的问题吗

原因 没写 @RunWith(SpringRunner.class)

报错java.lang.Exception: No runnable methods

报错原因有两个:,没有在方法上指定@Test和@Test的包导错了,spring-test需要的Junit是org.junit.Test,但是在@Test有两个包,另一个是org.junit.jupiter.api.Test,如果将org.junit.Test导错成了org.junit.jupiter.api.Test就会报这个错误,改正包之后问题解决

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/382371
推荐阅读
相关标签
  

闽ICP备14008679号