<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ?@Configuration,?@Bean,?@Import, and?@DependsOn 可以使用這些注釋 1.10.1 @Component @Repository 和數據訪問相關的。 @Component是通用類型, @Repository,?@Service, and?@Controller 是特定類型。 1.10.2 元注釋 @Service和 @Component效果一樣 @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Component // Spring will see this and treat @Service in the same way as @Component public @interface Service { // .... } } 1.10.3 自動偵測Bean @Configuration @ComponentScan(basePackages = "org.example") public class AppConfig { ... } } 使用XML的方式: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <context:component-scan base-package="org.example"/> </beans> 添加 context:component-scan需要包含<context:annotation-config> 使用ant時, 不要設置文件只讀。 http://stackoverflow.com/questions/19394570/java-jre-7u45-breaks-classloader-getresources). Furthermore, the?AutowiredAnnotationBeanPostProcessor?and?CommonAnnotationBeanPostProcessor?are both included implicitly when you use the component-scan element. 1.10.4 使用過濾進行客制掃描 可以使用?include-filter和exclude-filter?進行過濾。 @Configuration @ComponentScan(basePackages = "org.example", includeFilters = @Filter(type = FilterType.REGEX, pattern = ".*Stub.*Repository"), excludeFilters = @Filter(Repository.class)) public class AppConfig { ... } } Filter Type Example Expression Description annotation (default) org.example.SomeAnnotation An annotation to be present at the type level in target components. assignable org.example.SomeClass A class (or interface) that the target components are assignable to (extend/implement). aspectj org.example..*Service+ An AspectJ type expression to be matched by the target components. regex org\.example\.Default.* A regex expression to be matched by the target components class names. custom org.example.MyTypeFilter A custom implementation of the?org.springframework.core.type .TypeFilter?interface. xml 中配置如下: <beans> <context:component-scan base-package="org.example"> <context:include-filter type="regex" expression=".*Stub.*Repository"/> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/> </context:component-scan> </beans> 1.10.5 定義Bean的元數據 1.10.6 命名自動檢測的組件 @Service("myMovieLister") public class SimpleMovieLister { // ... } } 自己定義bean name規則 @Configuration @ComponentScan(basePackages = "org.example", nameGenerator = MyNameGenerator.class) public class AppConfig { ... } } <beans> <context:component-scan base-package="org.example" name-generator="org.example.MyNameGenerator" /> </beans> 1.10.7 自動偵測組件的范圍 默認是singleton @Scope("prototype") @Repository public class MovieFinderImpl implements MovieFinder { // ... } } 也可以定制范圍 1.10.8 使用注釋qualifier?元數據 @Component @Qualifier("Action") public class ActionMovieCatalog implements MovieCatalog { // ... } } qualifier?查找合適的bean 1.10.9 生成候選組件的索引 創建索引, 可以加快搜索的速度。 mvaen 需要加上: <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-indexer</artifactId> <version>5.0.8.RELEASE</version> <optional>true</optional> </dependency> </dependencies> 將會產生META-INF/spring.components 文件。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看