Skip to main content

One post tagged with "springboot"

View All Tags

spring boot 基础

· 2 min read

背景

常用的spring boot 问题收集

注解

@Bean@Component 注解优先使用哪个注入

好像得看代码实现,可能和版本有关

bean 和 component 注解优先使用哪个注入

@Component 的使用

@Component 挂在类上面 , @Bean 挂在方法里面,@Bean 更加灵活

[Component ]https://www.baeldung.com/spring-component-annotation

spring boot 启动流程

defineProxyClass:558, Proxy$ProxyBuilder (java.lang.reflect)
build:670, Proxy$ProxyBuilder (java.lang.reflect)
lambda$getProxyConstructor$0:429, Proxy (java.lang.reflect)
apply:-1, Proxy$$Lambda$20/0x0000000800c73468 (java.lang.reflect)
get:329, AbstractClassLoaderValue$Memoizer (jdk.internal.loader)
computeIfAbsent:205, AbstractClassLoaderValue (jdk.internal.loader)
getProxyConstructor:427, Proxy (java.lang.reflect)
newProxyInstance:1037, Proxy (java.lang.reflect)
run:302, AnnotationParser$1 (sun.reflect.annotation)
run:300, AnnotationParser$1 (sun.reflect.annotation)
executePrivileged:776, AccessController (java.security)
doPrivileged:318, AccessController (java.security)
annotationForMap:300, AnnotationParser (sun.reflect.annotation)
parseAnnotation2:289, AnnotationParser (sun.reflect.annotation)
parseAnnotations2:121, AnnotationParser (sun.reflect.annotation)
parseAnnotations:73, AnnotationParser (sun.reflect.annotation)
createAnnotationData:4068, Class (java.lang)
annotationData:4057, Class (java.lang)
getDeclaredAnnotations:4024, Class (java.lang)
getDeclaredAnnotations:449, AnnotationsScanner (org.springframework.core.annotation)
isKnownEmpty:489, AnnotationsScanner (org.springframework.core.annotation)
from:259, TypeMappedAnnotations (org.springframework.core.annotation)
from:371, MergedAnnotations (org.springframework.core.annotation)
from:359, MergedAnnotations (org.springframework.core.annotation)
from:339, MergedAnnotations (org.springframework.core.annotation)
<init>:86, StandardAnnotationMetadata (org.springframework.core.type)
from:173, StandardAnnotationMetadata (org.springframework.core.type)
introspect:134, AnnotationMetadata (org.springframework.core.type)
<init>:58, AnnotatedGenericBeanDefinition (org.springframework.beans.factory.annotation)
doRegisterBean:253, AnnotatedBeanDefinitionReader (org.springframework.context.annotation)
registerBean:147, AnnotatedBeanDefinitionReader (org.springframework.context.annotation)
register:137, AnnotatedBeanDefinitionReader (org.springframework.context.annotation)
load:161, BeanDefinitionLoader (org.springframework.boot)
load:136, BeanDefinitionLoader (org.springframework.boot)
load:129, BeanDefinitionLoader (org.springframework.boot)
load:698, SpringApplication (org.springframework.boot)
prepareContext:429, SpringApplication (org.springframework.boot)
run:322, SpringApplication (org.springframework.boot)
run:1342, SpringApplication (org.springframework.boot)
run:1331, SpringApplication (org.springframework.boot)
main:11, DemoApplication (com.example.demo)