当前位置:网站首页>Interview pit summary I

Interview pit summary I

2022-06-26 15:47:00 YMY_ six hundred and sixty-six

JVM Will two objects in the reference be recycled ?
Can't , Strongly referenced objects are not recycled

hashMap Why rewrite hashcode and .equals Method ?
It should be a static inner class Node Rewrote , For comparison key,value Decide whether to replace or append in the form of a linked list

rabbitmq If an exception occurs during message listening, how can I return to the queue and keep blocking ?
Return to the team and be consumed by other consumers

@Controller What does the annotation return ?
Return the template engine view name

@Component Annotations marked on interfaces or abstract classes can create injections bean Do you ?
You can't , Interface cannot be instantiated

spring How to inject mybatis Of mapper Interface ?
mybatis There is one MapperFactoryBean Class implements the spring Of FactoryBean Interface implements its getObject Method ,
Realized FactoryBean Interface bean It's a factory bean, factory bean Realized getObject The object returned by the method can be Autowired and Resource Inject

mysql What is the difference between a primary key index and a normal index ?
Clustered index and general index , Cluster index at B+ The leaf node of the tree , The normal index is located in B+ The non leaf node of a tree
1, The primary key index indexes the data , Then the ordinary index indexes the primary key ID value ( This is innodb in , But if it is myisam in , There is no difference between a primary key index and an ordinary index. They index data directly )
2, When you query with where id=x when , You only need to scan the primary key index once , Then get the corresponding data
But if it is a normal index for query , Then we will scan the ordinary index first , Get the primary key value , Then scan the primary key index , Get the data you need , This process is called back to table

spring When a declarative transaction will fail ?
@Transactional Apply to non public The way to decorate
@Transactional Annotation Properties propagation Setting error
@Transactional Annotation Properties rollbackFor Setting error
Method calls in the same class , Lead to @Transactional invalid ( For example, there is a class Test, One way of it A,A Call the methods of this class B( No matter how B Yes, it is public still private modification ), But the way A There is no declaration to annotate the transaction , and B There are methods . Then the external call method A after , Method B It doesn't work .)
In the program try/catch Exception handled
The database engine does not support transactions

spring Is there any other way to solve circular dependency besides L3 cache ?

RPC and RMI The difference between ?
RPC Is a remote procedure call ,RMI It's different JVM Object sharing between

spring bean Life cycle
spring bean The life cycle flow of the container is as follows :
1、Spring The container depends on bean Instantiate in definition bean.
2、Spring Fill all properties with dependency injection , Such as bean Configuration defined in .
3、 If bean Realization BeanNameAware Interface , Then the factory passes bean Of ID To call setBeanName().
4、 If bean Realization BeanFactoryAware Interface , The factory calls... By passing its own instance setBeanFactory().
5、 If it exists with bean Anything connected BeanPostProcessors, Call preProcessBeforeInitialization() Method .
6、 If bean It specifies init Method ( Of init-method attribute ), Then it will be called .
7、 Last , If it exists with bean Anything connected BeanPostProcessors, Will call postProcessAfterInitialization() Method .
8、 If bean Realization DisposableBean Interface , When spring When container is closed , Would call destory().
9、 If bean It specifies destroy Method ( Of destroy-method attribute ), Then it will be called

mysql How to start a slow query ?
slow_query_log Slow query on state
slow_query_log_file Slow query log storage location ( This directory needs MySQL The writable permission of the running account , Generally set as MySQL Data storage directory )
long_query_time How many seconds does the query take to record

The difference between filter interceptors ?
The underlying implementation principles are different , Filters are based on function callbacks , Interceptors are implemented by dynamic agents .
filter What we achieve is javax.servlet.Filter Interface , And this interface is in the Servlet As defined in the specification , Filter dependency servlet, That is to say, the filter Filter The use of Tomcat Equal container , It can only be found in web Used in program .
And the interceptor is spring A component of .
filter Filter After the request enters the container , But in entering servlet Pre treatment before , The request ends at servlet After processing .
Interceptor Interceptor It's asking for access servlet after , When entering Controller What was pretreated before .
For filter @Order Annotations control the execution order , adopt @Order Controls the level of the filter , The smaller the value, the higher the level, the earlier execution .
When configuring custom Filter when , If you don't specify order( If not specified, it defaults to Integer.MIN_VALUE),init() The execution order is random , but doFilter() Press filter The lexicographic order of the name is executed ;
Interceptor default execution order , It's the registration order , It can also be done through .order() Method to set the control manually , The smaller the value, the earlier to execute .

mysql What will not hit the index ?
The index specification is unreasonable ,sql The parser did not hit the index .
An index in a table is an index based on the largest number of data fields in the table ,sql The parser did not hit the index .( In fact, the index is useless , Finally, the global search )
bool Index the fields of ,sql Selector misses index .
Fuzzy query %like
The index column participates in the calculation , Using functions
Non leftmost prefix order
where Yes null Judge
where It's not equal to
or Operation has at least one field without index
The query result set that needs to be returned to the table is too large ( Beyond the scope of the configuration )

原网站

版权声明
本文为[YMY_ six hundred and sixty-six]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261527177747.html