由import javax.persistence.*;引用引起问题的思考(SpringBoot)

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

对比一下,发现本身的项目里面是少了 spring-boot-starter-data-jpa.jar包的引用。可是发现即便在Maven里面加入了spring-boot-starter-data-jpa包仍是没法排除错误。spring-boot

最后对比了一下,发现官方的代码案例里面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文件尾部包含了下述代码本身的项目里面是没有的。url

 

<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包过来,错误提示自动就消失了。spa

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

相关文章
相关标签/搜索