spring学习25-:通过构造函数依赖注入

简介: spring学习25-:通过构造函数依赖注入

image.png

pox.xml

<?xml version="1.0" encoding="UTF-8"?>
     <project xmlns="http://maven.apache.org/POM/4.0.0"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
         <modelVersion>4.0.0</modelVersion>
         <groupId>com.geyao</groupId>
         <artifactId>spring01geyao</artifactId>
         <version>1.0-SNAPSHOT</version>
         <dependencies>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-context</artifactId>
                 <version>4.3.13.RELEASE</version>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-test</artifactId>
                 <version>3.2.0.RELEASE</version>
             </dependency>
             <dependency>
                 <groupId>log4j</groupId>
                 <artifactId>log4j</artifactId>
                 <version>1.2.17</version>
             </dependency>
             <dependency>
                 <groupId>junit</groupId>
                 <artifactId>junit</artifactId>
                 <version>4.12</version>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-test</artifactId>
                 <version>4.3.4.RELEASE</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-test</artifactId>
                 <version>4.3.4.RELEASE</version>
                 <scope>test</scope>
             </dependency>
         </dependencies>
     </project>log4j.propreties
    ### 设置###
     log4j.rootLogger = ERROR,stdout
     ### 输出信息到控制抬 ###
     log4j.appender.stdout = org.apache.log4j.ConsoleAppender
     log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
     log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
     log4j.category.org.springframework.beans.factory=DEBUGAppconfig类
    package com.geyao.demo.config;
     import com.geyao.demo.Service.impl.UserServiceNormal;
     import com.geyao.demo.dao.UserDao;
     import com.geyao.demo.dao.impl.UserDaoNormal;
     import org.springframework.context.annotation.Bean;
     import org.springframework.context.annotation.ComponentScan;
     import org.springframework.context.annotation.Configuration;
     @Configuration
     public class Appconfig {
         @Bean
         public UserDao userDaoNormal(){
             System.out.println("创建UserDao对象"
             );
             return  new UserDaoNormal();
         }
         @Bean
         public UserServiceNormal userServiceNormal(){
             System.out.println("创建userservice对象");
             UserDao userDao=userDaoNormal();
             return new UserServiceNormal(userDao);
         }
     }userservice类
    package com.geyao.demo.dao.impl;
     import com.geyao.demo.dao.UserDao;
     import org.springframework.stereotype.Repository;
     public class UserDaoNormal implements UserDao {
         public void add(){
             System.out.println("添加到数据库中...");
         }
     }Userdao
    package com.geyao.demo.dao;
     public interface UserDao {
         void add();
     }UserServiceNormal类
    package com.geyao.demo.Service.impl;
     import com.geyao.demo.Service.UserService;
     import com.geyao.demo.dao.UserDao;
     import org.springframework.stereotype.Service;
     public class UserServiceNormal implements UserService {
         private UserDao userDao;
         public UserServiceNormal() {
             super();
         }
         public UserServiceNormal(UserDao userDao){
             this.userDao=userDao;
         }
         public void add(){
             userDao.add();
         }
     }UserService类
    package com.geyao.demo.Service;
     public interface UserService {
         void add();
     }UserServiceTest类
    package com.geyao.demo.service;
     import com.geyao.demo.Service.UserService;
     import com.geyao.demo.config.Appconfig;
     import org.junit.Test;
     import org.junit.runner.RunWith;
     import org.springframework.beans.factory.annotation.Autowired;
     import org.springframework.test.context.ContextConfiguration;
     import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
     @RunWith(SpringJUnit4ClassRunner.class)
     @ContextConfiguration(classes = Appconfig.class)
     public class UserServiceTest {
         @Autowired
         private UserService userService;
         @Test
         public void testAdd(){
             userService.add();
         }
     }运行结果
    [DEBUG] 2019-11-01 22:25:32,893 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:32,898 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:32,927 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:32,931 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
     WARNING: An illegal reflective access operation has occurred
     WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/Users/geyao/.m2/repository/org/springframework/spring-core/4.3.13.RELEASE/spring-core-4.3.13.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
     WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
     WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
     WARNING: All illegal access operations will be denied in a future release
     [DEBUG] 2019-11-01 22:25:33,125 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,125 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,127 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,157 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,158 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,158 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,159 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,167 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,176 method:org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:730)
     Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@43195e57: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,appconfig,userDaoNormal,userServiceNormal]; root of factory hierarchy
     [DEBUG] 2019-11-01 22:25:33,177 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,177 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,177 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,179 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerProcessor'
     [DEBUG] 2019-11-01 22:25:33,180 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'org.springframework.context.event.internalEventListenerProcessor'
     [DEBUG] 2019-11-01 22:25:33,184 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'org.springframework.context.event.internalEventListenerProcessor' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,189 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'org.springframework.context.event.internalEventListenerProcessor'
     [DEBUG] 2019-11-01 22:25:33,190 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerFactory'
     [DEBUG] 2019-11-01 22:25:33,190 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'org.springframework.context.event.internalEventListenerFactory'
     [DEBUG] 2019-11-01 22:25:33,191 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'org.springframework.context.event.internalEventListenerFactory' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,196 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'org.springframework.context.event.internalEventListenerFactory'
     [DEBUG] 2019-11-01 22:25:33,196 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'appconfig'
     [DEBUG] 2019-11-01 22:25:33,197 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'appconfig'
     [DEBUG] 2019-11-01 22:25:33,198 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'appconfig' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,204 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'appconfig'
     [DEBUG] 2019-11-01 22:25:33,204 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'userDaoNormal'
     [DEBUG] 2019-11-01 22:25:33,204 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'userDaoNormal'
     [DEBUG] 2019-11-01 22:25:33,207 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'appconfig'
     创建UserDao对象
     [DEBUG] 2019-11-01 22:25:33,247 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'userDaoNormal' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,251 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'userDaoNormal'
     [DEBUG] 2019-11-01 22:25:33,251 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'userServiceNormal'
     [DEBUG] 2019-11-01 22:25:33,252 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'userServiceNormal'
     [DEBUG] 2019-11-01 22:25:33,252 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'appconfig'
     创建userservice对象
     [DEBUG] 2019-11-01 22:25:33,254 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'userDaoNormal'
     [DEBUG] 2019-11-01 22:25:33,256 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'userServiceNormal' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,259 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'userServiceNormal'
     [DEBUG] 2019-11-01 22:25:33,260 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'org.springframework.context.event.internalEventListenerFactory'
     [DEBUG] 2019-11-01 22:25:33,316 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'lifecycleProcessor'
     [DEBUG] 2019-11-01 22:25:33,325 method:org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:86)
     Processing injected element of bean 'com.geyao.demo.service.UserServiceTest': AutowiredFieldElement for private com.geyao.demo.Service.UserService com.geyao.demo.service.UserServiceTest.userService
     [DEBUG] 2019-11-01 22:25:33,330 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'userServiceNormal'
     [DEBUG] 2019-11-01 22:25:33,331 method:org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.registerDependentBeans(AutowiredAnnotationBeanPostProcessor.java:535)
     Autowiring by type from bean name 'com.geyao.demo.service.UserServiceTest' to bean named 'userServiceNormal'
     添加到数据库中...
     [DEBUG] 2019-11-01 22:25:33,340 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'lifecycleProcessor'
     [DEBUG] 2019-11-01 22:25:33,341 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:512)
     Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@43195e57: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,appconfig,userDaoNormal,userServiceNormal]; root of factory hierarchy
<?xml version="1.0" encoding="UTF-8"?>
     <project xmlns="http://maven.apache.org/POM/4.0.0"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
         <modelVersion>4.0.0</modelVersion>
         <groupId>com.geyao</groupId>
         <artifactId>spring01geyao</artifactId>
         <version>1.0-SNAPSHOT</version>
         <dependencies>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-context</artifactId>
                 <version>4.3.13.RELEASE</version>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-test</artifactId>
                 <version>3.2.0.RELEASE</version>
             </dependency>
             <dependency>
                 <groupId>log4j</groupId>
                 <artifactId>log4j</artifactId>
                 <version>1.2.17</version>
             </dependency>
             <dependency>
                 <groupId>junit</groupId>
                 <artifactId>junit</artifactId>
                 <version>4.12</version>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-test</artifactId>
                 <version>4.3.4.RELEASE</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-test</artifactId>
                 <version>4.3.4.RELEASE</version>
                 <scope>test</scope>
             </dependency>
         </dependencies>
     </project>log4j.propreties
    ### 设置###
     log4j.rootLogger = ERROR,stdout
     ### 输出信息到控制抬 ###
     log4j.appender.stdout = org.apache.log4j.ConsoleAppender
     log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
     log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
     log4j.category.org.springframework.beans.factory=DEBUGAppconfig类
    package com.geyao.demo.config;
     import com.geyao.demo.Service.impl.UserServiceNormal;
     import com.geyao.demo.dao.UserDao;
     import com.geyao.demo.dao.impl.UserDaoNormal;
     import org.springframework.context.annotation.Bean;
     import org.springframework.context.annotation.ComponentScan;
     import org.springframework.context.annotation.Configuration;
     @Configuration
     public class Appconfig {
         @Bean
         public UserDao userDaoNormal(){
             System.out.println("创建UserDao对象"
             );
             return  new UserDaoNormal();
         }
         @Bean
         public UserServiceNormal userServiceNormal(){
             System.out.println("创建userservice对象");
             UserDao userDao=userDaoNormal();
             return new UserServiceNormal(userDao);
         }
     }userservice类
    package com.geyao.demo.dao.impl;
     import com.geyao.demo.dao.UserDao;
     import org.springframework.stereotype.Repository;
     public class UserDaoNormal implements UserDao {
         public void add(){
             System.out.println("添加到数据库中...");
         }
     }Userdao
    package com.geyao.demo.dao;
     public interface UserDao {
         void add();
     }UserServiceNormal类
    package com.geyao.demo.Service.impl;
     import com.geyao.demo.Service.UserService;
     import com.geyao.demo.dao.UserDao;
     import org.springframework.stereotype.Service;
     public class UserServiceNormal implements UserService {
         private UserDao userDao;
         public UserServiceNormal() {
             super();
         }
         public UserServiceNormal(UserDao userDao){
             this.userDao=userDao;
         }
         public void add(){
             userDao.add();
         }
     }UserService类
    package com.geyao.demo.Service;
     public interface UserService {
         void add();
     }UserServiceTest类
    package com.geyao.demo.service;
     import com.geyao.demo.Service.UserService;
     import com.geyao.demo.config.Appconfig;
     import org.junit.Test;
     import org.junit.runner.RunWith;
     import org.springframework.beans.factory.annotation.Autowired;
     import org.springframework.test.context.ContextConfiguration;
     import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
     @RunWith(SpringJUnit4ClassRunner.class)
     @ContextConfiguration(classes = Appconfig.class)
     public class UserServiceTest {
         @Autowired
         private UserService userService;
         @Test
         public void testAdd(){
             userService.add();
         }
     }运行结果
    [DEBUG] 2019-11-01 22:25:32,893 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:32,898 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:32,927 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:32,931 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
     WARNING: An illegal reflective access operation has occurred
     WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/Users/geyao/.m2/repository/org/springframework/spring-core/4.3.13.RELEASE/spring-core-4.3.13.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
     WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
     WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
     WARNING: All illegal access operations will be denied in a future release
     [DEBUG] 2019-11-01 22:25:33,125 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,125 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,127 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,157 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,158 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,158 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,159 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,167 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,176 method:org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:730)
     Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@43195e57: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,appconfig,userDaoNormal,userServiceNormal]; root of factory hierarchy
     [DEBUG] 2019-11-01 22:25:33,177 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,177 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,177 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
     [DEBUG] 2019-11-01 22:25:33,179 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerProcessor'
     [DEBUG] 2019-11-01 22:25:33,180 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'org.springframework.context.event.internalEventListenerProcessor'
     [DEBUG] 2019-11-01 22:25:33,184 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'org.springframework.context.event.internalEventListenerProcessor' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,189 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'org.springframework.context.event.internalEventListenerProcessor'
     [DEBUG] 2019-11-01 22:25:33,190 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'org.springframework.context.event.internalEventListenerFactory'
     [DEBUG] 2019-11-01 22:25:33,190 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'org.springframework.context.event.internalEventListenerFactory'
     [DEBUG] 2019-11-01 22:25:33,191 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'org.springframework.context.event.internalEventListenerFactory' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,196 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'org.springframework.context.event.internalEventListenerFactory'
     [DEBUG] 2019-11-01 22:25:33,196 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'appconfig'
     [DEBUG] 2019-11-01 22:25:33,197 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'appconfig'
     [DEBUG] 2019-11-01 22:25:33,198 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'appconfig' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,204 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'appconfig'
     [DEBUG] 2019-11-01 22:25:33,204 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'userDaoNormal'
     [DEBUG] 2019-11-01 22:25:33,204 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'userDaoNormal'
     [DEBUG] 2019-11-01 22:25:33,207 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'appconfig'
     创建UserDao对象
     [DEBUG] 2019-11-01 22:25:33,247 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'userDaoNormal' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,251 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'userDaoNormal'
     [DEBUG] 2019-11-01 22:25:33,251 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
     Creating shared instance of singleton bean 'userServiceNormal'
     [DEBUG] 2019-11-01 22:25:33,252 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:449)
     Creating instance of bean 'userServiceNormal'
     [DEBUG] 2019-11-01 22:25:33,252 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'appconfig'
     创建userservice对象
     [DEBUG] 2019-11-01 22:25:33,254 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'userDaoNormal'
     [DEBUG] 2019-11-01 22:25:33,256 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
     Eagerly caching bean 'userServiceNormal' to allow for resolving potential circular references
     [DEBUG] 2019-11-01 22:25:33,259 method:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:485)
     Finished creating instance of bean 'userServiceNormal'
     [DEBUG] 2019-11-01 22:25:33,260 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'org.springframework.context.event.internalEventListenerFactory'
     [DEBUG] 2019-11-01 22:25:33,316 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'lifecycleProcessor'
     [DEBUG] 2019-11-01 22:25:33,325 method:org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:86)
     Processing injected element of bean 'com.geyao.demo.service.UserServiceTest': AutowiredFieldElement for private com.geyao.demo.Service.UserService com.geyao.demo.service.UserServiceTest.userService
     [DEBUG] 2019-11-01 22:25:33,330 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'userServiceNormal'
     [DEBUG] 2019-11-01 22:25:33,331 method:org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.registerDependentBeans(AutowiredAnnotationBeanPostProcessor.java:535)
     Autowiring by type from bean name 'com.geyao.demo.service.UserServiceTest' to bean named 'userServiceNormal'
     添加到数据库中...
     [DEBUG] 2019-11-01 22:25:33,340 method:org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:251)
     Returning cached instance of singleton bean 'lifecycleProcessor'
     [DEBUG] 2019-11-01 22:25:33,341 method:org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:512)
     Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@43195e57: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,appconfig,userDaoNormal,userServiceNormal]; root of factory hierarchy
相关文章
|
13天前
|
前端开发 Java 数据库
SpringBoot学习
【10月更文挑战第7天】Spring学习
31 9
|
14天前
|
XML Java 数据格式
Spring学习
【10月更文挑战第6天】Spring学习
17 1
|
18天前
|
Java 测试技术 开发者
springboot学习四:Spring Boot profile多环境配置、devtools热部署
这篇文章主要介绍了如何在Spring Boot中进行多环境配置以及如何整合DevTools实现热部署,以提高开发效率。
41 2
|
18天前
|
前端开发 Java 程序员
springboot 学习十五:Spring Boot 优雅的集成Swagger2、Knife4j
这篇文章是关于如何在Spring Boot项目中集成Swagger2和Knife4j来生成和美化API接口文档的详细教程。
41 1
|
18天前
|
Java API Spring
springboot学习七:Spring Boot2.x 拦截器基础入门&实战项目场景实现
这篇文章是关于Spring Boot 2.x中拦截器的入门教程和实战项目场景实现的详细指南。
16 0
springboot学习七:Spring Boot2.x 拦截器基础入门&实战项目场景实现
|
18天前
|
Java API Spring
springboot学习六:Spring Boot2.x 过滤器基础入门&实战项目场景实现
这篇文章是关于Spring Boot 2.x中过滤器的基础知识和实战项目应用的教程。
17 0
springboot学习六:Spring Boot2.x 过滤器基础入门&实战项目场景实现
|
18天前
|
Java 关系型数据库 MySQL
springboot学习五:springboot整合Mybatis 连接 mysql数据库
这篇文章是关于如何使用Spring Boot整合MyBatis来连接MySQL数据库,并进行基本的增删改查操作的教程。
29 0
springboot学习五:springboot整合Mybatis 连接 mysql数据库
|
18天前
|
Java 关系型数据库 MySQL
springboot学习四:springboot链接mysql数据库,使用JdbcTemplate 操作mysql
这篇文章是关于如何使用Spring Boot框架通过JdbcTemplate操作MySQL数据库的教程。
17 0
springboot学习四:springboot链接mysql数据库,使用JdbcTemplate 操作mysql
|
18天前
|
Java 测试技术 Spring
springboot学习三:Spring Boot 配置文件语法、静态工具类读取配置文件、静态工具类读取配置文件
这篇文章介绍了Spring Boot中配置文件的语法、如何读取配置文件以及如何通过静态工具类读取配置文件。
22 0
springboot学习三:Spring Boot 配置文件语法、静态工具类读取配置文件、静态工具类读取配置文件
|
18天前
|
Java Spring
springboot 学习十一:Spring Boot 优雅的集成 Lombok
这篇文章是关于如何在Spring Boot项目中集成Lombok,以简化JavaBean的编写,避免冗余代码,并提供了相关的配置步骤和常用注解的介绍。
62 0