***************************APPLICATION FAILED come START***************************Description:Parameter 0 of technique setApplicant in webService.controller.RequestController required a p of kind "com.service.applicant.Applicant" that can not it is in found.Action:Consider specifying a p of kind "com.service.applicant.Applicant" in her configuration. I have actually never viewed this error prior to but it"s odd the the
Autowire没有工作。项目结构如下:

Applicant Interface

申请人界面

public user interface Applicant TApplicant findBySSN(String ssn) throw ServletException; void deleteByssn(String ssn) throws ServletException; void createApplicant(TApplicant tApplicant) litter ServletException; void updateApplicant(TApplicant tApplicant) throw ServletException; perform getAllApplicants() throw ServletException; ApplicantImpl

应用程序模板


Transactionalpublic class ApplicantImpl implements Applicant private static Log log in = LogFactory.getLog(ApplicantImpl.class); personal TApplicantRepository applicantRepo;
Override public list getAllApplicants() throw ServletException perform applicantList = applicantRepo.findAll(); return applicantList; currently I should be able to just Autowire Applicant and be able come access, but in this case it is not working when I speak to it in my
RequestMapping(value="/", technique = RequestMethod.GET) public String helloWorld() shot perform applicantList = applicant.getAllApplicants(); for (TApplicant tApplicant : applicantList) System.out.println("Name: "+tApplicant.getIndivName()+" SSN "+tApplicant.getIndSsn()); return "home"; record (ServletException e) e.printStackTrace(); return "error"; } ------------------------UPDATE 1-----------------------

------------------------更新1-----------------------

I added

我补充道


ComponentScan("module-service")public course WebServiceApplication extend SpringBootServletInitializer
Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) return builder.sources(WebServiceApplication.class); public revolution void main(String<> args) SpringApplication.run(WebServiceApplication.class, args); and also the error go away but nothing happened. However when ns commented out everything handling Applicant in the RestController front to including
ComponentScan() I was able to return a cable the UI, thus meaning my RestController was working, currently it is gift skipped. Ns ugly Whitelabel Error web page now.

You are watching: Consider defining a bean of type

错误消失了,但什么也没发生。然而,在添加
ComponentScan()之前,我在RestController中注释掉了所有与申请人有关的内容,我能够在UI中返回一个字符串,这意味着我的RestController正在工作,现在它被跳过了。我现在看到了白色标签错误页面

---------------------UPDATE 2------------------------------

---------------------更新2------------------------------

I added the basic package the the p it to be complaining about. Error reads:

我添加了它抱怨的bean的基本包。错误读取:

***************************APPLICATION FAILED to START***************************Description:Parameter 0 of an approach setApplicantRepo in com.service.applicant.ApplicantImpl compelled a bean of kind "com.delivery.service.request.repository.TApplicantRepository" that could not it is in found.Action:Consider defining a p of form "com.delivery.request.request.repository.TApplicantRepository" in your configuration. I added
ComponentScan

我添加了
ComponentScan


SpringBootApplication
ComponentScan("com.delivery.service","com.delivery.request")public class WebServiceApplication extend SpringBootServletInitializer
Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) return builder.sources(WebServiceApplication.class); public revolution void main(String<> args) SpringApplication.run(WebServiceApplication.class, args); ----------------------------Update 3----------------------

----------------------------更新3----------------------

adding:

添加:


SpringBootApplication
ComponentScan("com")public course WebServiceApplication extends SpringBootServletInitializer { still is complaining around my ApplicantImpl class which
Autowires mine repo TApplicantRepository right into it.

仍然在抱怨我的应用程序impl类
Autowires将我的repoTApplicantRepository放入其中


我要回答
有人评论时请通知我
提交回复 取消
*

Mr.Player making awesome assets

It could be since the project has actually been damaged down into different modules.


SpringBootApplication
ComponentScan("com.delivery.request")
EntityScan("com.delivery.domain")
EnableJpaRepositories("com.delivery.repository")public class WebServiceApplication extend SpringBootServletInitializer {
reply (2)
first Dec 2017 • 10:15am

*

mirror Making awesome products
There is a chance...You might be absent
Service,
Repository annotation top top your respective implementation classes.


reply (2)
1st Dec 2017 • 10:15am
*

Carlho do awesome products

Your Applicant class is not scanned the seems. By default all packages beginning with the root as the course where you have actually put
SpringBootApplication will be scanned.

suppose her main course "WebServiceApplication" is in "com.service.something", climate all materials that fall under "com.service.something" is scanned, and "com.service.applicant" will not it is in scanned.

You can either restructure her packages such that "WebServiceApplication" falls under a root package and all other materials becomes part of the root package. Or friend can include
SpringBootApplication(scanBasePackages="com.service.something","com.service.application") etc such that "ALL" contents are scanned and initialized in the spring container.

Update based upon comment

If you have actually multiple modules that space being regulated by maven/gradle, every spring needs is the package come scan. You tell spring to scan "com.module1" and also you have an additional module which has its source package name as "com.module2", those materials wont be scanned. You can also tell spring to scan "com" which will certainly then scan all materials in "com.module1." and "com.module2."


answer (2)
first Dec 2017 • 10:15am
*

29271074 make awesome products

Basically this happens when you have actually your course Application in "another package". For example:

com.server - Applicacion.class ( I settle the difficulty with this in the Application.class


SpringBootApplication
ComponentScan ("com.server", "com.server.config")
EnableMongoRepositories ("com.server.repository") // this deal with the problem Another much less elegant method is to: placed all the construction classes in the same package.


reply (2)
1st Dec 2017 • 10:15am
*

141723099 make awesome assets

In my instance I had actually a terrible mistake. I placed
Service as much as the service interface.

To deal with it, I put
Service top top the implementation the service paper and it operated for me.


answer (2)
1st Dec 2017 • 10:15am
143610346 do awesome commodities

If a p is in the very same package in which it is
Autowired, then it will never cause such one issue. However, beans are not available from different packages through default. Come fix this issue follow these actions :

Import complying with in your key class:import org.springframework.context.annotation.ComponentScan;add annotation over your main course :


ComponentScan(basePackages = "your.company.domain.package")public class SpringExampleApplication public static void main(String<> args) SpringApplication.run(SpringExampleApplication.class, args);
reply (2)
first Dec 2017 • 10:15am
143736926 making awesome assets
i think you have the right to make it streamlined by annotated her repository through
Repository, climate it will be permitted automatically by spring Framework.


reply (2)
1st Dec 2017 • 10:15am
142538012 making awesome commodities

In my case these two choices worked.

in //
ComponentScan ("myapp", "myapp.resources","myapp.services")include also the package i m sorry holds the Application.class in the list, or

Simply add
EnableAutoConfiguration; it instantly recognizes every the spring beans.


reply (2)
1st Dec 2017 • 10:15am
winter Making awesome assets

I confronted with familiar problem in my Maven multi-module job with Spring boots 2. The trouble was related to naming of my packages in below Maven modules.


SpringBootApplication incapsulate a several component prefer -
ComponentScan,
EnableAutoConfiguration, jpa-repositories, json-serialization and also so on. And he places
ComponentScan in com.*******.space package. This component of packages com.*******.space should be common for all modules.

For fixing it:

You should rename every module packages. Various other words you had to have in every packages in every Maven modules - the very same parent part. For example - com.*******.space likewise you have to move her entry allude to this package - com.*******.space
reply (2)
first Dec 2017 • 10:15am
120711236 make awesome products

This can also happen if you space using Lombok and you include the
RequiredArgsConstructor and
NonNull for fields however some the your fields are no to be injected in the constructor. This is only among the possibilities to gain the the exact same error.

parameter 0 forced a bean of kind MissingBeanName that can not it is in found

In my instance the error told me what Controller the difficulty was in, ~ removing
NonNull the application began fine


reply (2)
first Dec 2017 • 10:15am
120711236 do awesome products

Moving the Springbootapplication(application.java) file to an additional package addressed the problem for me. Save it separate from the controllers and repositories.


answer (2)
first Dec 2017 • 10:15am
Manner do awesome products
Important:

For anybody that was brought here by googling the generic bean error message, however who is actually trying to include a feign client to your Spring Boot application via the
FeignClient annotation on your client interface, no one of the above solutions will work for you.

To deal with the problem, you need to add the
EnableFeignClients annotation come your applications class, choose so:


SpringBootApplication// ... (other pre-existing annotations) ...
EnableFeignClients // side note: including a
ComponentScan(...) beneath
SpringBootApplication is redundant, and also your concept should flag it thus (IntelliJ IDEA does, in ~ least).


reply (2)
first Dec 2017 • 10:15am
46933952 make awesome assets

I sought online for solution but it seems there is no one proper solution to my case: at the really beginning, whatever works well together follows:


Slf4j
Service
AllArgsConstructor(onConstructor =
__(
Autowired))public class GroupService exclusive Repository repository; private business service; Then i am trying to include a map come cache something and it i do not care this:


Slf4j
Service
AllArgsConstructor(onConstructor =
__(
Autowired))public class GroupService exclusive Repository repository; private organization service; Map testMap; Boom!

Description:Parameter 4 of constructor in *.GroupService required a bean of type "java.lang.String" that might not it is in found.Action:Consider specifying a p of form "java.lang.String" in your configuration. I removed the
AllArgsConstructor(onConstructor =
__(
Autowired)) and include
Autowired because that each repository and service other than the Map. It simply works together before.


Slf4j
Servicepublic class SecurityGroupService
Autowired private Repository repository;
Autowired private business service; Map testMap; hope this might be helpful.


answer (2)
first Dec 2017 • 10:15am
103545801 making awesome commodities

It worked for me after including below annotation in application:


ComponentScan("com.seic.deliveryautomation.mapper")

I was acquiring the below error:

"parameter 1 of constructor in forced a p of type mapper that might not be found:


reply (2)
1st Dec 2017 • 10:15am
8321347 make awesome products
Configuration annotation will just solve the error


answer (2)
1st Dec 2017 • 10:15am
7485434 making awesome products

You"ll likewise get this error if you accidentally define the very same bean in two various classes. That happened to me. The error article was misleading. When I gotten rid of the extra bean, the concern was resolved.


answer (2)
1st Dec 2017 • 10:15am
97923299 make awesome commodities

I confronted the exact same issue. Mongo DB repository was identified by spring boot, however it was not developing Bean because that a repository user interface that prolonged the mongo repository.

The problem in my situation was incorrect version specification in maven pom because that "spring + mango". I have changed the artifact"s group id and also it all operated like magic. No annotations essential as spring boot took care of everything.

During my difficulty resolution, i was all over web looking for solutions and also realized the this difficulty is actually job configuration related, anyone facing this worry should an initial check their job setup and allow debug from feather to get much more details top top failure and pay close attention to where precisely in the process, the creation has failed.


answer (2)
first Dec 2017 • 10:15am
UndergroundHK do awesome commodities

Try configuring the job structure as given below:

Put all the repo, service, packages in the boy package of the main package:

package com.leisure.moviemax; //Parent parcel
SpringBootApplication
PropertySource(value="classpath:conf.properties") public course MoviemaxApplication implements CommandLineRunner { package com.leisure.moviemax.repo; //child package
Repositorypublic interface UsrRepository extends JpaRepository {
reply (2)
1st Dec 2017 • 10:15am
143239404 making awesome commodities
SpringBootApplication
MapperScan("com.developer.project.mapper")public course Application public static void main(String<> args) SpringApplication.run(Application.class, args);
reply (2)
1st Dec 2017 • 10:15am
Arsenal making awesome commodities
This can happen if the
Service class is marked abstract.


reply (2)
1st Dec 2017 • 10:15am
137416954 making awesome commodities

In my case this error appear because my income was wrong, because that example, utilizing spring, the import automatically appear:

import org.jvnet.hk2.annotations.Service; but i needed:

import org.springframework.stereotype.Service;
reply (2)
1st Dec 2017 • 10:15am
118560649 make awesome commodities
If your course dependency is regulating by spring then this issue may take place if we forgot to include default/empty arg constructor within our POJO class.


reply (2)
1st Dec 2017 • 10:15am
97429504 do awesome products

My error was the I had included:

org.springframework.data spring-data-jpa 2.2.5.RELEASE rather of:

org.springframework.boot spring-boot-starter-data-jpa
reply (2)
first Dec 2017 • 10:15am
15595693 do awesome commodities
that might aid somebody. I had the exact same problem, exact same error message, same everything. I tried services from other answers, didn"t aid until ns realised that the bean i am using has the exact same name as the one the is actually been autowired. It happened in the midst of refactor, therefore I had to rename the class, which resulted positively. Cheers


answer (2)
1st Dec 2017 • 10:15am
134770996 do awesome assets

I had actually a situation where i must inject RestTemplate into a company class. However, the RestTemplate can not be choose up by the business class. What i did is to develop a wrapper class under the exact same package as key application and mark the wrapper together Component and autowire this component in the organization class. Difficulty solved. Hope it also works for you


reply (2)
1st Dec 2017 • 10:15am
65323803 making awesome products

I think, friend are missing the
Bean annotation in your RequestController

Add the p in her file, this solved my concern I acquired this systems while ns was discovering Spring boots from tutorialspoint

private Applicant applicant;
Bean public Applicant applicant() return new Applicant();
answer (2)
1st Dec 2017 • 10:15am
8321347 making awesome assets
If friend use user interface you can extends CrudRepository with
Repository annotation.


reply (2)
first Dec 2017 • 10:15am
127915173 make awesome commodities

Issue can also appeared when you use per instance
EnableMongoRepositories(YOUR_MONGO_REPOSITORIES_PACKAGE) and later you change the name the package surname or moved it in another place.

See more: Project Free Tv Love And Hip Hop Hollywood Season 5 Episode 5 Watch Online

Very often confronted it within a multi-module maven project and also spring boot


reply (2)
1st Dec 2017 • 10:15am
Stanley do awesome products

There is a possibility that you space trying to
autowired
an interface prior to implement the interface.

example solution:

**HomeController.java** course HomeController
Autowired UserService userService; ..... ---------------------------------------------------------------------- **UserService.java** public user interface UserService User findByUsername(String username); ..... ----------------------------------------------------------------------- **UserServiceImpl.java**
Service public class UserServiceImpl implements UserService public User findByUsername(String username) return userDao.findByUsername(username); .... This is not italic, and (https://example.com)
reply (2)
1st Dec 2017 • 10:15am

*
提示
内容来源于网络,仅用于大数据研究机器学习用,不得转载及用于商业用途
Tags标签
所有标签 ›
*
globalunicom.com