Spring

Batch Insert with JPA and Spring

我只是一个虾纸丫 提交于 2021-02-19 11:43:21
问题 I'm using Spring Framework and JPA to insert beans into my database. I need to insert almost 8000 entities, and this can delay too much. Why should I disable "second level cache" in Hibernate hibernate.cache.use_second_level_cache false When I set a "hibernate.jdbc.batch_size 20" in Hibernate, will it insert my beans like this? INSERT INTO VALUES (1),(2),(3)...(20); INSERT INTO VALUES (21),(2),(3)...(40); The documentation says: "Hibernate disables insert batching at the JDBC level

SpringBoot项目新建遇到问题整理(一)

梦想与她 提交于 2021-02-19 11:04:02
1.新建了一个SpringBoot项目:只引用需要用到的spring boot相关的jar包,除此之外没有任何的配置 启动application.java报错: APPLICATION FAILED TO START *************************** Description: Cannot determine embedded database driver class for database type NONE Action: If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active). --——————>原因:因为spring boot只要你在pom中引入了spring-boot-starter-data-jpa,他就会默认需要加载数据库相关的配置 你要是没有在配置文件中配置数据库相关信息,它会加载默认的配置(不存在的) 然后就报错了, 所以你要是要用数据库相关的东西 你就完善配置 不用数据库相关的东西

闲鱼服务端架构演进历程

孤街醉人 提交于 2021-02-19 10:48:47
作者 | 万佳 嘉宾 | 巴滕 闲鱼是从阿里巴巴某一茶水间“游”出来的。2014 年 6 月,闲鱼诞生,2 年时间不到,其用户数突破 1 亿。如今,它已经成为国内最知名的闲置交易平台,拥有数亿用户,年交易额超过 2000 亿,并开启了一个万亿市场。闲鱼能有今天的成绩,离不开背后的技术迭代、架构升级和技术人的付出。闲鱼初创时,架构设计面临着哪些挑战?闲鱼服务端架构在 6 年时间里是怎样演进的?闲鱼在服务端架构上还在做哪些新尝试?...... 带着这些问题,InfoQ 记者采访了闲鱼技术部高级技术专家巴滕。自闲鱼创立以来,他一直参与闲鱼服务端架构持续演进的工作。 1、闲鱼的业务特点 据巴滕介绍,闲鱼是一个典型的双边市场,买家和卖家规模相互影响,“如何同时服务好买家和卖家双方,这是我们一直努力的方向”。 对买家来说,要提升商品发现效率,帮助他们尽快地买到商品。 对卖家而言,要降低发布门槛,帮助他们尽快地把商品卖出去。 对于平台,要持续优化用户的使用体验,比如降低纠纷和欺诈问题,同时持续扩大市场规模。 2、闲鱼服务端最初的架构设计 众所周知,闲鱼的前身是 PC 时代的淘宝二手,它属于淘宝的一个小频道。当时,闲鱼整体业务规模和用户量都非常小。基本上,单一应用就支撑所有业务,并且整体架构和服务完全是面向 PC 设计的。 “当时,服务端同学需要时常编写 Velocity 模板代码

Spring boot 2.0.2, interception of Cloud Stream annotations with Aop not working anymore

断了今生、忘了曾经 提交于 2021-02-19 10:00:33
问题 I tried to keep the title as explicit and simple as possible. Basically, I need to intercept the usage of Cloud stream's @Input and @Output annotations. This is needed to automatically add a specific ChannelInterceptor to each MessageChannel. (The behaviour in the preSend method will be slightly different whether the message has been produced or consumed). For example, if I declare this advice @Around("@annotation(org.springframework.cloud.stream.annotation.Input)") public Object

Spring boot 2.0.2, interception of Cloud Stream annotations with Aop not working anymore

你说的曾经没有我的故事 提交于 2021-02-19 09:58:33
问题 I tried to keep the title as explicit and simple as possible. Basically, I need to intercept the usage of Cloud stream's @Input and @Output annotations. This is needed to automatically add a specific ChannelInterceptor to each MessageChannel. (The behaviour in the preSend method will be slightly different whether the message has been produced or consumed). For example, if I declare this advice @Around("@annotation(org.springframework.cloud.stream.annotation.Input)") public Object

How to fix 'java.lang.NoClassDefFoundError: org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource$GraphTraversalSourceStub'?

馋奶兔 提交于 2021-02-19 09:25:04
问题 I am trying to initialize an in-memory graph using TinkerGraph. Firstly, i have defined the bean in my context xml file and tried to initialise the TinkerGraph. My intention is to unit test the classes that i have created for forming the gremlin queries, the end queries that i get from these classes are in the form of a string, so in order to execute them through the TinkerGraph, i have the used the approach given in the following post: Get Gremlin query as a String and execute it in java

UnknownHostException when trying to connect to heroku-postgres from local Springboot project with Spring JPA

岁酱吖の 提交于 2021-02-19 09:23:38
问题 I am trying to connect to heroku-postgres with Spring JPA when I am getting an unknownHostException. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.Driver.makeConnection(Driver.java

UnknownHostException when trying to connect to heroku-postgres from local Springboot project with Spring JPA

﹥>﹥吖頭↗ 提交于 2021-02-19 09:20:19
问题 I am trying to connect to heroku-postgres with Spring JPA when I am getting an unknownHostException. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.Driver.makeConnection(Driver.java

UnknownHostException when trying to connect to heroku-postgres from local Springboot project with Spring JPA

痞子三分冷 提交于 2021-02-19 09:19:20
问题 I am trying to connect to heroku-postgres with Spring JPA when I am getting an unknownHostException. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.Driver.makeConnection(Driver.java

How to handle Spring Boot/ Spring Data projections with entity relationships (nested projection)

旧城冷巷雨未停 提交于 2021-02-19 09:04:24
问题 I'm trying to get nested projections working in Spring Boot. I have 2 entities, Parent and Child , wheras Parent has a unidirectional @OneToMany relationship to Child . Here are the classes: (using Lombok-Annotations) @Entity @Data @NoArgsConstructor public class Parent { @Id @GeneratedValue private long id; private String basic; private String detail; @OneToMany(fetch = FetchType.EAGER) private List<Child> children; public Parent(String basic, String detail, List<Child> children) { this