简体   繁体   English

SpringBoot需要找不到类型为'boolean'的bean

[英]SpringBoot required a bean of type 'boolean' that could not be found

I search stackoverflow quite a bit, but didn't find a solution for my Problem. 我搜索了很多stackoverflow,但没有找到解决我的问题的方法。 I gte the following error when deploying a SpringBoot app as a WAR file to Tomcat 8, localy it does work fine 将SpringBoot应用程序作为WAR文件部署到Tomcat 8时出现以下错误,但它确实可以正常工作

***************************|
APPLICATION FAILED TO START|
***************************|
Description:
Parameter 0 of method getJobapplicationDTO in 
com.tts.scp.converter.config.ScpDestinationConfig required a bean of 
type 'boolean' that could not be found.
Action:
Consider defining a bean of type 'boolean' in your configuration.

There is an Interface 有一个接口

public interface HttpProviderConfig {
  JobApplicationDTO getJobapplicationDTO(boolean printResume, boolean 
  printCoverletter, boolean printAttachments, String jobApplicationId);
} 

and two implementing classes 和两个实施类

@Configuration
@Profile("production")
public class ScpDestinationConfig implements HttpProviderConfig{

private static final Logger logger = 
LoggerFactory.getLogger(ScpDestinationConfig.class);

@Override
@Bean
public JobApplicationDTO getJobapplicationDTO (boolean resume, boolean coverletter ...

and second class 第二等

@Configuration
@Profile("dev")
public class LocalDestinationConfig implements HttpProviderConfig{

private static final Logger logger = 
LoggerFactory.getLogger(LocalDestinationConfig.class);

@Override
@Bean
public JobApplicationDTO getJobapplicationDTO (boolean resume, boolean coverletter ...

And a rest service 和休息服务

@RestController
public class ConverterController {

private static final Logger logger = 
LoggerFactory.getLogger(ConverterController.class);

@Autowired
@Lazy
private HttpProviderConfig client;

@GetMapping(path = "/convertDocuments", produces=MediaType.APPLICATION_PDF_VALUE)
public void convertedDocument(@RequestParam(defaultValue = "true") String printResume,
        @RequestParam(defaultValue = "true") String printCoverLetter,
        @RequestParam(defaultValue = "true") String printAttachments, @RequestParam String jobApplicationId,
        HttpServletResponse response) throws IOException {

    JobApplicationDTO jobApplicationDTO = client.getJobapplicationDTO(

So waht I don't understand how Tomcat can't find primitive datatypes like boolean and why it does work when i run it locally. 因此,我不了解Tomcat如何找不到诸如boolean之类的原始数据类型,以及当我在本地运行它时为什么它能工作。

any help would be appreciated 任何帮助,将不胜感激

Regards Mathias 关于Mathias

So waht I don't understand how Tomcat can't find primitive datatypes like boolean and why it does work when i run it locally. 因此,我不了解Tomcat如何找不到诸如boolean之类的原始数据类型,以及当我在本地运行它时为什么它能工作。

This has nothing to do with it. 这与它无关。

In your configuration you have a @Bean declaration like: 在您的配置中,您有一个@Bean声明,例如:

@Bean
public JobApplicationDTO getJobapplicationDTO (boolean resume, ...)

So basically you ask Spring to manage the JobApplicationDTO for you. 因此,基本上,您要求Spring为您管理JobApplicationDTO Spring then needs resume and othe parameters to construct JobApplicationDTO for you and it can't find them so you get the error you get. Spring然后需要resume和其他参数来为您构造JobApplicationDTO ,但找不到它们,因此您得到了错误。

I think you should not be annotating your get...DTO methods with @Bean in the first place. 我认为您不应该首先使用@Bean注释get...DTO方法。 And your ...Config classes actually don't look like a @Configuration for me, rather like a @Service or @Component . 而且您的...Config类对我而言实际上不像@Configuration ,而是@Service@Component

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 字段需要在springboot中找不到的bean - Field required a bean which could not be found in springboot 需要一个找不到类型的 bean - Required a bean of type that could not be found 无法解决Springboot gradle的错误-需要找不到类型为'com.myapp.services.UserDetailRepository'的bean - Unable to solve error of Springboot gradle - required a bean of type 'com.myapp.services.UserDetailRepository' that could not be found 字段需要类型的 bean ... 无法找到 - 使用 Springboot 和 Postgres 时出错 - Field required a bean of type ... that could not be found - Error when using Springboot and Postgres SpringBoot JUnit 测试说 Field 需要一个找不到的 'com.labprog.egressos.service.ContatoService' 类型的 bean - SpringBoot JUnit test says Field required a bean of type 'com.labprog.egressos.service.ContatoService' that could not be found com.springboot.todoController.TodoController中的字段todoService需要找不到“ com.springboot.todo.TodoService”类型的Bean - Field todoService in com.springboot.todoController.TodoController required a bean of type 'com.springboot.todo.TodoService' that could not be found 需要一个无法通过Spring Boot找到的类型的bean - Required a bean of type that could not be found Spring Boot 需要一个无法找到 REST API 类型的 bean - Required a bean of type that could not be found REST API (…)中的字段memberRepo需要一个找不到类型的bean - Field memberRepo in (…) required a bean of type that could not be found 错误需要找不到类型为“XXX”的 bean - Error required a bean of type 'XXX' that could not be found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM