我得到以下错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method setApplicant in webService.controller.RequestController required a bean of type 'com.service.applicant.Applicant' that could not be found.
Action:
Consider defining a bean of type 'com.service.applicant.Applicant' in your configuration.
我以前从未见过这个错误,但奇怪的是@autowire不能工作。以下是项目结构:
申请者界面
public interface Applicant {
TApplicant findBySSN(String ssn) throws ServletException;
void deleteByssn(String ssn) throws ServletException;
void createApplicant(TApplicant tApplicant) throws ServletException;
void updateApplicant(TApplicant tApplicant) throws ServletException;
List<TApplicant> getAllApplicants() throws ServletException;
}
应用程序
@Service
@Transactional
public class ApplicantImpl implements Applicant {
private static Log log = LogFactory.getLog(ApplicantImpl.class);
private TApplicantRepository applicantRepo;
@Override
public List<TApplicant> getAllApplicants() throws ServletException {
List<TApplicant> applicantList = applicantRepo.findAll();
return applicantList;
}
}
现在我应该能够自动连接申请者并能够访问,但是在这种情况下,当我在@RestController:
中调用它时,它就不起作用了
@RestController
public class RequestController extends LoggingAware {
private Applicant applicant;
@Autowired
public void setApplicant(Applicant applicant){
this.applicant = applicant;
}
@RequestMapping(value="/", method = RequestMethod.GET)
public String helloWorld() {
try {
List<TApplicant> applicantList = applicant.getAllApplicants();
for (TApplicant tApplicant : applicantList){
System.out.println("Name: "+tApplicant.getIndivName()+" SSN "+tApplicant.getIndSsn());
}
return "home";
}
catch (ServletException e) {
e.printStackTrace();
}
return "error";
}
}
---------------更新1--------------------------------
我添加了
@SpringBootApplication
@ComponentScan("module-service")
public class WebServiceApplication extends SpringBootServletInitializer {
@Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(WebServiceApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(WebServiceApplication.class, args);
}
}
错误消失了,但什么也没有发生。但是,当我在添加@componentScan()
之前注释掉了RestController
中与Applicator
有关的所有内容时,我能够返回一个UI
的字符串,这意味着我的RestController
正在工作,现在它被跳过了。我丑陋的whitelabel错误页面
现在。
-------------更新2-------------------------------------------
我添加了它所抱怨的bean的基本包。错误读取:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method setApplicantRepo in com.service.applicant.ApplicantImpl required a bean of type 'com.delivery.service.request.repository.TApplicantRepository' that could not be found.
Action:
Consider defining a bean of type 'com.delivery.request.request.repository.TApplicantRepository' in your configuration.
我添加了@componentscan
@SpringBootApplication
@ComponentScan({"com.delivery.service","com.delivery.request"})
public class WebServiceApplication extends SpringBootServletInitializer {
@Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(WebServiceApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(WebServiceApplication.class, args);
}
}
----------------更新3-------------------------------
添加:
@SpringBootApplication
@ComponentScan("com")
public class WebServiceApplication extends SpringBootServletInitializer {
仍然在抱怨我的ApplicanTIMPL
类,它将@AutoWires
我的repoTApplicanTRepository
放入其中。
这可能是因为项目被分解为不同的模块。
@SpringBootApplication
@ComponentScan({"com.delivery.request"})
@EntityScan("com.delivery.domain")
@EnableJpaRepositories("com.delivery.repository")
public class WebServiceApplication extends SpringBootServletInitializer {
我试图在Spring Boot中创建一个简单的REST服务。在我使用CrudRepository之前,一切都很好。现在我得到了这个错误- ***应用程序启动失败 描述: 公司中的现场er。Spring靴。io。受雇者EmployeeService需要“company”类型的bean。Spring靴。io。受雇者找不到EmployeeRepo“”。 措施: 考虑定义一个“company”类型的bea
描述:com.mongotest.demo.seeder中构造函数的参数0需要类型为“com.mongotest.repositories.studentrepository”的bean,但找不到该bean。 pom.xml
当我运行main类时会出错。 错误: 主类: 我的包裹是这样的:
我有一个Java Spring Boot项目,我正在其中创建一个post请求。代码如下所示: 主要: 但是,当我运行该项目时,我会得到以下错误: 感谢您对此的任何帮助!非常感谢,
下午好,我正在尝试使用Spring Boot运行SOAP服务,但出现以下错误: 应用程序启动失败 描述: 我知道也许这应该是个愚蠢的错误,但我看不出来 附件MI代码: SpringBootSoapApp.java ClienteServiceImpl.java client.xsd 应用程序.属性 我的项目结构 我试图遵循以下示例:https://www.javaspringclub.com/pu