Home > Back-end >  Injection in @ the bean of annotation problem! Help!!!!!
Injection in @ the bean of annotation problem! Help!!!!!

Time:10-17

Dear bosses, trouble to help me see what is wrong with the
 this is the controller. The Java file
 for springmvc. The XML configuration file
application. The XML configuration files, ask for help!!! Thank you very much!!!!!!!!!!

CodePudding user response:

Look at the interface is userservice gave comments

CodePudding user response:

reference response: 1/f, red ribbon
look at the interface is userservice gave comments
interface did not give comments

CodePudding user response:

Behind it there was a row the error
The Dependency annotations: {@ org. Springframework. Beans. Factory. The annotation, Autowired (required=true)}

CodePudding user response:

You configure the SAO surface does not contain the Service of Pakege: com. Zxy. Core. Service. Impl, so need to amend the above base - package, please try to specify directly to the top part of base - package="com. Zxy. Core"

CodePudding user response:

black and white apes reference 4 floor response:
& lt; ! - configuration scanner - & gt;
You configure the SAO surface does not contain the Service of Pakege: com. Zxy. Core. Service. Impl, so need to amend the above base - package, please try to specify directly to the top part of base - package="com. Zxy. Core"

Hello, errors when org. Springframework. Beans. Factory. UnsatisfiedDependencyException: Error creating bean with the name 'userService' : Unsatisfied dependency expressed through the field 'userDao; Nested exception is org. Springframework. Beans. Factory. NoSuchBeanDefinitionException: No qualifying bean of type 'com. Zxy. Core. Dao. UserDao' available: expected at further 1 bean which qualifies as autowire candidate. The Dependency annotations: {@ org. Springframework. Beans. Factory. The annotation, Autowired (required=true)

But I wrote UserDao only interface

CodePudding user response:

Scheme 2: in the Application of the Application (start) on unified use @ MapperScan, (recommended)

Package com. Gavinbj. Confmng;

The import org. Mybatis. Spring. The annotation. MapperScan;
The import org. Springframework. Boot. SpringApplication;
The import org. Springframework. Boot. Autoconfigure. SpringBootApplication;

/* *
* @ SpringBootApplication mark this is the main program SpringBoot project class
*/
@ MapperScan (com. Gavinbj. Confmng. Persistence. "mapper")

CodePudding user response:

@autowired is the default by type matching bean to injection, you used when registered service implementation class attribute specifies the bean name, you are either in the controller interface injection @ the Resource, or under the @autowired add a @ the Qualifier to specify the name of the injection of bean,

CodePudding user response:

WX Spring Chinese community understanding of relevant knowledge

CodePudding user response:

The
reference 3 floor weixin_43371771 response:
behind it there was a row this error
The Dependency annotations: {@ org. Springframework. Beans. Factory. The annotation, Autowired (required=true)}

Found that you don't like to add annotations controller components, the service, the repository, component, userdao will add @ repository to above show that it is a dao components, IOC management for spring to scan it, can the @autowired dependency injection

CodePudding user response:

Don't scan to the interface

  • Related