由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包过来,错误提示自动就消失了。
该段代码的工作原理待分析。
由import javax.persistence.*;引用引发问题的思考(SpringBoot)的更多相关文章
- 调用EntityManagerFactory错误:The import javax.persistence cannot be resolved
缺少jar包:hibernate-jpa-2.0-api-1.0.0.Final.jar
- 使用javax.persistence注解配置PO对象
JPA注解持久化类很方便,需要jar包:ejb3-persistence.jar下载 import java.io.Serializable; import javax.persistence.Col ...
- @Index用法——javax.persistence.Index
package com.springup.utiku.model; import java.io.Serializable; import javax.persistence.Entity; impo ...
- The import javax.servlet.http.HttpServletRequest cannot be resolved
Error: The import javax.servlet cannot be resolved The import javax.servlet.http.HttpServletRequest ...
- 在Myeclipse buildpath 加server lib (server runtime)/项目导入时报错:The import javax.servlet.http.HttpServletRequest cannot be resolved
来源于:http://blog.csdn.net/dingqinghu/article/details/8805922 http://yl-fighting.iteye.com/blog/140946 ...
- 项目导入时报错:The import javax.servlet.http.HttpServletRequest cannot be resolved 解决方法
Error: The import javax.servlet cannot be resolved The import javax.servlet.http.HttpServletRequest ...
- [Spring Data JPA问题]Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException
JPQL如下: @Modifying(clearAutomatically = true) @Query("UPDATE SyncTestFromTKDO SET stuAns = '' w ...
- Java import javax.servlet 出错
Error: The import javax.servlet cannot be resolved The import javax.servlet.http.HttpServletRequest ...
- ejb3persistence.jar javax.persistence的注解配置
JPA注解持久化类很方便,需要jar包:ejb3-persistence.jar.我用以下三个类来说明用法. sh原创 转载请注明: http://67566894.iteye.com/blog/6 ...
随机推荐
- 882. Reachable Nodes In Subdivided Graph
题目链接 https://leetcode.com/contest/weekly-contest-96/problems/reachable-nodes-in-subdivided-graph/ 解题 ...
- 测试URL
http://localhost:8080/dmonitor-webapi/monitor/vm/342?r=1410331220921&indexes=cpu&indexes=mem ...
- NHibernate获取实体配置信息(表名,列名等等)
// 注意这里有个&符号,并不是写错了,而是约定 就是这样写的ctx.GetObject("&SessionFactory") 这是官网地址http://nhfor ...
- Java操作XML的工具:JAXB
JavaArchitecture for XML Binding (JAXB) 是一个业界的标准,是一项可以根据XML Schema产生Java类的技术.该过程中,JAXB也提供了将XML实例文档反向 ...
- Perl 学习笔记-正则表达式应用篇
1.以 m// 进行匹配 如: m/roger/ , /roger/ 是它的简写; 在说明 qw// 时可以选择使用任何成对的定界符, 对应m//匹配也可以, 如写成: m(roger) ...
- 【小梅哥SOPC学习笔记】NIOS II工程目录改变时project无法编译问题
解决NIOS II工程移动在磁盘上位置后project无法编译问题 说明:本文档于2017年3月4日由小梅哥更新部分内容,主要是增加了讲解以Quartus II13.0为代表的经典版本和以15.1为代 ...
- modelsim使用常见问题及解决办法集锦 ②
二.Error deleting “msim_transcript” Error deleting “msim_transcript”:permission denied. Check the Nat ...
- 关于Java中的几种特殊类与接口,及特殊的创建实例的方法
Java中有一些特殊的类,在教材中讲解的不深,但是确实非常有用的,这里总结一下,里面用到的有网上搜到的内容,这里表示下感谢. 一.成员内部类 成员内部类是在一个内中定义的另外一个类,这个类属于其上的类 ...
- linux安装memcache及memcache扩展
一.安装libevent# wget http://www.monkey.org/~provos/libevent-2.0.12-stable.tar.gz# tar zxf libevent-2.0 ...
- react-dnd使用介绍
核心API 想要灵活使用,就先知道几个核心API DragSource 用于包装你需要拖动的组件,使组件能够被拖拽(make it draggable) DropTarget 用于包装接收拖拽元素的组 ...