[英]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.