Spring

当我去了网易上班,才知道为什么人人都想进大厂了,附上我进网易的面试宝典!

巧了我就是萌 提交于 2021-02-11 06:43:32
前言 首先自我介绍一下,本人南京某渣渣本科毕业,毕业后一直待在一家不大不小的公司里面摸鱼等死,今年疫情的时候差点被裁员裁掉,自己想了想总不能就这样下去了吧,前几个月决心辞职。辞职后去面了几家公司有过的有被毙的 也没拿到满意的offer,自己在家闲下来学习了几个月,上个月朋友给了一个网易的内推,想着去试试,结果过了! 我这里准备了一线大厂面试资料和我原创的超硬核PDF技术文档,以及我为大家精心准备的多套大厂面试题(不断更新中),有需要的朋友 点击这里备注csdn,自行下载即可 希望大家都能找到心仪的工作! java基础相关 1.手撕代码。牛客题霸上的原题,可以去看看:NC20数字字符串转化成IP地址 2.定义Integer x=20 Integer y=200 在内存里是个什么过程? 3.volite关键字的原理?它能保证原子性吗?AtomicInteger底层怎么实现的? 4.threadLocal关键字有用过吗?如果没有重写initialValue方法就直接get会怎样? 5.hashMap与concurrentHashMap原理和区别? 6.hashMap什么情况下会出现循环链表?concurrentHashMap写的时候用什么锁?7.RenteenLock底层是怎么保证线程安全的? 8.反射能获取到父类的私有方法吗?怎么防止反射破坏单例模式? 9.描述下JVM内存模型

Spring Boot Health Check - SQS Consumer

旧街凉风 提交于 2021-02-11 06:36:25
问题 Is there a Spring Boot Actuator Health Check endpoint for SQS? I have built a SQS consumer and I want to check if SQS is up and running. I am not using JMSlistener for connecting to SQS but rather using Spring Cloud Libraries. I implemented the below health check endpoint. This returns the below error when I delete the queue and try to hit the health check endpoint. If there is a connectivity issue or if the SQS service goes down , will I be getting a similar error which will eventually cause

How config gson in Spring boot?

强颜欢笑 提交于 2021-02-11 05:59:03
问题 Spring Boot 2 In application.yml http: converters: preferred-json-mapper: gson Now I write class with custom settings for Gson : public class GsonUtil { public static GsonBuilder gsonbuilder = new GsonBuilder(); public static Gson gson; public static JsonParser parser = new JsonParser(); static { // @Exclude -> to exclude specific field when serialize/deserilaize gsonbuilder.addSerializationExclusionStrategy(new ExclusionStrategy() { @Override public boolean shouldSkipField(FieldAttributes

Exception “java.lang.IllegalStateException: Existing transaction detected in JobRepository.” after upgrading spring batch from 2.1.1 to 4.1.1 version

邮差的信 提交于 2021-02-11 05:54:38
问题 I have a Junit test case which run a batch job. Previously It was working when I have spring batch version 2.1.2. But once I upgraded to version 4.1.1, am getting below exception java.lang.IllegalStateException: Existing transaction detected in JobRepository. Please fix this and try again (e.g. remove @Transactional annotations from client). I have tried removing @Transactional from test class. But still getting an exception.I guess the error is due to two transactions. But still removal of

Localhost vs 127.0.0.1 in Spring Framework

一笑奈何 提交于 2021-02-11 05:46:16
问题 I am attempting to connect a spring rest service to a client which is an android device. I have followed this tutorial on creating my service: https://spring.io/guides/gs/rest-service/ Which by default runs the Spring Service on port 8080. My issue is that on localhost:8080/test I get a correct output from my service but on 127.0.0.1:8080/test I get 404 Not found. Is there any reason for this? I specifically need to connect to 127.0.0.1 for debugging purposes with an android emulator. Thank

Localhost vs 127.0.0.1 in Spring Framework

老子叫甜甜 提交于 2021-02-11 05:44:46
问题 I am attempting to connect a spring rest service to a client which is an android device. I have followed this tutorial on creating my service: https://spring.io/guides/gs/rest-service/ Which by default runs the Spring Service on port 8080. My issue is that on localhost:8080/test I get a correct output from my service but on 127.0.0.1:8080/test I get 404 Not found. Is there any reason for this? I specifically need to connect to 127.0.0.1 for debugging purposes with an android emulator. Thank

Spring Integration - Log time taken for whole file processing

我们两清 提交于 2021-02-11 05:01:57
问题 I have a scenario to split a large files to small chunks using File Inbound, Splitter, Transformer and File Outbound adapter. I would like to know how long it took to process the file starting from read to split to write back. How do I achieve this functionality? Any help is appreciated. <file:inbound-channel-adapter directory="/Documents" filename-pattern="test.txt" channel="inputFiles"> <int:poller fixed-delay="0"/> </file:inbound-channel-adapter> <int:channel id="inputFiles"> <int

Spring Data Projection loads additional Fields

故事扮演 提交于 2021-02-11 04:57:35
问题 I have a small issue. Let’s assume I have this Entity: import lombok.Data; import javax.persistence.*; import java.util.Set; @Data @Entity public class Person { enum SEX {F, M} @Id @GeneratedValue private Long id; @OrderBy @Enumerated(EnumType.STRING) @ElementCollection(fetch = FetchType.EAGER) private Set<SEX> sexes; private String firstName; private String lastName; } Because at some points I do not want to load the first and last name, I use Projections (https://docs.spring.io/spring-data

Should you expose a primary key in REST API URLs?

元气小坏坏 提交于 2021-02-11 03:09:17
问题 I'm very new to Spring. I'm trying to create a REST API using Spring Boot and I'm stuck whether to expose my user's primary key or not which also happens to be their email. Something like api/user/example@gmail.com . A big part of me says it's okay since it would sensible to expose it as it is the identifier for that specific record when viewing, deleting, and updating. Is there a security risk for this? What is the best practice for such implementation? Right now I'm combining the

Should you expose a primary key in REST API URLs?

久未见 提交于 2021-02-11 03:00:00
问题 I'm very new to Spring. I'm trying to create a REST API using Spring Boot and I'm stuck whether to expose my user's primary key or not which also happens to be their email. Something like api/user/example@gmail.com . A big part of me says it's okay since it would sensible to expose it as it is the identifier for that specific record when viewing, deleting, and updating. Is there a security risk for this? What is the best practice for such implementation? Right now I'm combining the