Take note of any questions you ask

  • Redis data type

String list set zset hash

  • A singleton of spring Controller

How to verify that its singleton is unsafe, and what is the solution

Controllers are singletons by default; do not use non-static member variables, otherwise data logic will be messed up.

Singletons are not thread-safe because of them. If you must use non-static variables, use @scope(prototype) on the class and set it to multi-instance mode.

Solution: 1. Do not define member variables in controller. 2. In case you have to define a non-static member variable, annotate @scope (” prototype “) and set it to multi-example mode. 3. Use the ThreadLocal variable in Controller

  • The engine of mysql
  • Is Integer equal to equals or ==? 128 or IntegerCache is involved

We use object.equals () comparisons whenever we compare reference objects. Of course, for the above problem, you can use == if the value of Integer is in the range -128 to 127, and equals for the rest

  • Turn the list String []
/ / String [] to turn a List < String >
String[] arr = new String[]{"s1"."s2"."s3"};
List<String> list = Arrays.asList(arr); 

/ / a List < String > turn String []
List<String> list = new ArrayList<String>();
list.add("s1");
list.add("s2");
list.add("s3");
String[] arr = list.toArray(new String[list.size()]);
Copy the code
  • List<String> list1List<String> list2Removing duplicate elements
public static void main(String[] args) {
        List<String> list1 = new ArrayList<>();
        list1.add("a");
        list1.add("1");
        list1.add("b");
        list1.add("e");
        list1.add("x");

        List<String> list2 = new ArrayList<>();
        list2.add("a");
        list2.add("1");


        List<String> list3 = new ArrayList<>();
        list3.addAll(list1);
// list3.removeAll(list2); [b, e, x] [b, e, x]
        list3.retainAll(list2); // repeat elements in list3
        System.out.println(list3);
    }
Copy the code
  • OSI 7 layer network model

Physical layer, data link layer, network layer, transmission layer, session layer, presentation layer, application layer

  • SQL optimization
  • #{} and ${} in mybaits
  • Spring ioc source
  • Mysql > select * from ‘sex’; select * from ‘sex’;

In InnoDB, every table has a clustered index. If the table has a primary key defined, the primary key is the clustered index. A table has only one clustered index and the rest are normal indexes. When a common index is used to query data, the system loads the common index first and searches for the primary key of the actual row through the common index. The primary key is then used to query the corresponding row through the clustered index. This loop queries all rows.

If a clustered index is directly searched in full, there is no need to switch back and forth between normal and clustered indexes. Why the gender field is not suitable for indexing. You can see that the same SQL is much slower with an index than without. Reference (blog.csdn.net/zxcc1314/ar…).

  • How to resolve maven JAR conflicts?

Use

to exclude conflicting JAR packages

  • SQL defines the index, but does not use the index in the query?