zoukankan      html  css  js  c++  java
  • 由import javax.persistence.*;引用引发问题的思考(SpringBoot)

    在学习SpringBoot的 JPA时候增加一个实体类的时候发现import包的时候一直报错。

    对比一下,发现自己的项目里面是少了 spring-boot-starter-data-jpa.jar包的引用。但是发现即使在Maven里面加入了spring-boot-starter-data-jpa包还是无法排除错误。

    最后对比了一下,发现官方的代码案例里面spring-boot-starter-data-jpa包在Maven Project里面看是既能看到spring-boot-starter-data-jpa包的引用,也能看到spring-boot-starter-data-jpa包的前置引用。但是自己的项目里面只能看到spring-boot-starter-data-jpa.jar包的引用,看不见spring-boot-starter-data-jpa.jar包的前置引用。

    最后面对比了一下发现官方案例代码里面POM文件尾部包含了下述代码自己的项目里面是没有的。

    <repositories>
            <repository>
                <id>spring-releases</id>
                <name>Spring Releases</name>
                <url>https://repo.spring.io/libs-release</url>
            </repository>
            <repository>
                <id>org.jboss.repository.releases</id>
                <name>JBoss Maven Release Repository</name>
                <url>https://repository.jboss.org/nexus/content/repositories/releases</url>
            </repository>
        </repositories>
    
        <pluginRepositories>
            <pluginRepository>
                <id>spring-releases</id>
                <name>Spring Releases</name>
                <url>https://repo.spring.io/libs-release</url>
            </pluginRepository>
        </pluginRepositories>

     在自己项目的POM文件中加入上述代码,发现Maven重新引用了好多新的Jar包过来,错误提示自动就消失了。

    该段代码的工作原理待分析。

  • 相关阅读:
    [LeetCode] Next Greater Element I
    [LeetCode] Fizz Buzz
    [LeetCode] Reverse String
    [LeetCode] Average of Levels in Binary Tree
    [LeetCode] Encode and Decode TinyURL
    推荐一个计算机视觉图书:python计算机视觉编程
    leetcode 9 Palindrome Number 回文数
    ios swift模仿qq登陆界面,xml布局
    leetcode 26 Remove Duplicates from Sorted Array
    leetcode 88 Merge Sorted Array
  • 原文地址:https://www.cnblogs.com/Bruce_H21/p/9890713.html
Copyright © 2011-2022 走看看