2018年8月21日
摘要: springjpa如何搭建,前面的文章已经介绍过了。这一篇介绍下如何进行简单的增删改查。 student表ddl如下 CREATE TABLE `student` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(255) DEFAULT 阅读全文
posted @ 2018-08-21 16:14 幽人月 阅读(2551) 评论(0) 推荐(0)
  2018年8月16日
摘要: 如何用构建springboot项目见往期文章。 这篇文章的主要目的是快速搭建websocket的项目。所以概念就不介绍了。 下面就直奔主题主题 项目结构: pom文件 WebSocketConfig配置类 TestController验证用的controller类 webSocket.html 启动 阅读全文
posted @ 2018-08-16 00:25 幽人月 阅读(940) 评论(1) 推荐(0)
  2018年8月15日
摘要: https://start.spring.io/ pom文件 项目结构 controller和启动类 index.html index.css 启动项目(run DemoApplication类) 访问 http://localhost:8080/index 访问结果: 阅读全文
posted @ 2018-08-15 23:56 幽人月 阅读(239) 评论(0) 推荐(0)
  2018年7月25日
摘要: 声明Bean的注解: @Component组件,没有明确的角色。 @Service在业务逻辑层(service层)使用。 @Repository在数据访问层(dao层)使用。 @Controller在展现层(MVC-->SpringMVC)使用 注入Bean的注解,一般情况下通用 @Autowire 阅读全文
posted @ 2018-07-25 23:21 幽人月 阅读(105) 评论(0) 推荐(0)
  2018年7月13日
摘要: 很多情况下除了使用定义好的crud,我们需要为Repository提供一些自定义的实现。这时候使用自定义Repository可以满足要求。 这里我们新增一个sayHello的方法。 继承JpaRepository是为了继续使用spring自己实现好的那些方法。 下面完成MyRepository的实现 阅读全文
posted @ 2018-07-13 14:48 幽人月 阅读(259) 评论(0) 推荐(0)
  2018年3月1日
摘要: (一)依赖 (二)数据库连接设置(application.properties) (三)entity编写 (四)对应entity的Repository的编写 (五)测试 整体的结构如下图 阅读全文
posted @ 2018-03-01 10:21 幽人月 阅读(179) 评论(0) 推荐(0)
  2018年2月28日
摘要: 通常是使用Collections的sort方法 第一种是java类实现了Comparable接口 第二种是普通的java类,在传给sort方法时同时传递给他比较的方式。 先来个第一种方法的demo 比较时只用把BookBean的List传给sort方法即可 输出如下 第二种是通过传递比较方式来进行排 阅读全文
posted @ 2018-02-28 14:37 幽人月 阅读(168) 评论(0) 推荐(0)
  2018年1月23日
摘要: 官方给的用法解释 entityName select x from #{#entityName} x Inserts the entityName of the domain type associated with the given Repository. The entityName is r 阅读全文
posted @ 2018-01-23 16:30 幽人月 阅读(101) 评论(0) 推荐(0)
摘要: 这边的测试基于springboot 引入jpa的依赖 编写entity 编写Repository 一般开发而言通过继承CrudRepository的方式。先以这个为例。 先简单看下CrudRepository这个类 这边已经定义好了很多方法。 在开发中,我们可以直接通过注入StudentReposi 阅读全文
posted @ 2018-01-23 16:24 幽人月 阅读(178) 评论(0) 推荐(0)
  2018年1月22日
摘要: Querydsl是jpa的扩展 (一)引入Querydsl的相关依赖和插件 (二)定义enetity(@Data在文末有说明) (三)定义Repository (四)查询 我们先用spring data jpa官网给的使用方法 首先让我们自己的Repository继承QueryDslPredicat 阅读全文
posted @ 2018-01-22 16:50 幽人月 阅读(2714) 评论(0) 推荐(0)