preface
Due to the details of the content is too much, so only part of the knowledge point screenshots out of the rough introduction, each small node there are more detailed content!
Sorted out a Java core knowledge points. It covers JVM, locking, concurrency, Java reflection, Spring principle, microservices, Zookeeper, database, data structure and many other knowledge points.
If you need to access this document, scan below
The body of the
if(isPrototypeCurrentlyInCreation(beanName)) { throw new BeanCurrentlyInCreationException(beanName); }Copy the code
Spring addresses loop dependencies
-
SingletonObjects is our most familiar friend, commonly known as “singleton pool” or “container”, the cache where the singleton Bean is created and completed.
-
The singletonFactories map creates the original factory of the Bean
-
EarlySingletonObjects is an early reference to a mapping Bean, meaning that the Bean in the Map is not complete or even called a “Bean”, just an Instance.
The nature of circular dependencies
-
Takes some of the specified class instances as singletons
-
The fields in the class are also instantiated as singletons
-
Support for circular dependencies
public class A { private B b; }// class B: public class B {private A A; }Copy the code
Private static Map<String, Object> cacheMap = new HashMap<>(2); private static Map<String, Object> cacheMap = new HashMap<>(2); Public static void main(String[] args) {// pretend to scan the object Class[] classes = {a.class, b.class}; // Pretend the project initializes the instantiation of all beansfor(Class aClass : classes) { getBean(aClass); } // check System.out.println(getBean(B.class).getA() == getBean(A.class)); System.out.println(getBean(A.class).getB() == getBean(B.class)); } @sneakythrows private static <T> T getBean(Class<T> beanClass) {// This article uses the Class name to replace the bean naming rule String beanName = beanClass.getSimpleName().toLowerCase(); // If it is already a bean, return it directlyif (cacheMap.containsKey(beanName)) { return(T) cacheMap.get(beanName); } / / the Object itself is instantiated Object Object. = beanClass getDeclaredConstructor (). The newInstance (); Cachemap. put(beanName, object); Field[] fields = object.getClass().getDeclaredFields(); Field[] fields = object.getClass().for (Field field : fields) { field.setAccessible(true); // Get the class <? > fieldClass = field.getType(); String fieldBeanName = fieldClass.getSimpleName().toLowerCase(); Field. Set (Object, cachemap.containsKey (fieldBeanName)? cacheMap.get(fieldBeanName) : getBean(fieldClass)); } // When the property is filled, returnreturn (T) object; }Copy the code
What? The essence of the question is two sum!
class Solution { public int[] twoSum(int[] nums, int target) { Map<Integer, Integer> map = new HashMap<>(); for (int i = 0; i < nums.length; i++) { int complement = target - nums[i]; if (map.containsKey(complement)) { return new int[] { map.get(complement), i }; } map.put(nums[i], i); } throw new IllegalArgumentException("No two sum solution"); }}Copy the code
At the end
Due to the details of the content is too much, so only part of the knowledge point screenshots out of the rough introduction, each small node there are more detailed content!
Sorted out a Java core knowledge points. It covers JVM, locking, concurrency, Java reflection, Spring principle, microservices, Zookeeper, database, data structure and many other knowledge points.
If you need to access this document, scan below