我收到以下错误:
***************************
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.
Run Code Online (Sandbox Code Playgroud)
我之前从未见过这个错误,但@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;
}
Run Code Online (Sandbox Code Playgroud)
ApplicantImpl
@Service
@Transactional
public class ApplicantImpl implements Applicant {
private static Log …Run Code Online (Sandbox Code Playgroud) 我很确定我过去在JPA 2.0中使用了@Entity注释的bean的某种自动检测,但我无法弄清楚如何.你如何做而不是将每个bean列在classpersistence.xml 中的XML元素中?
执行单元测试时将抛出以下错误。请告知我是否遗漏了什么。我正在使用 Spring Boot 2.1.1.RELEASE。谢谢!
java.lang.IllegalStateException:无法检索@EnableAutoConfiguration 基础包
应用程序-test.yml
spring:
profiles: test
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
username : xxx
password : xxx
jpa:
hibernate:
ddl-auto: update
cache:
type: simple
Run Code Online (Sandbox Code Playgroud)
应用程序库.java
@Repository
public interface AppRepository extends CrudRepository<App, Integer> {
App findFirstByAppId(String appId);
}
Run Code Online (Sandbox Code Playgroud)
AppRepositoryTest.java
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = {AppRepository.class})
@EnableConfigurationProperties
@DataJpaTest
@ActiveProfiles("test")
public class AppRepositoryTest {
@Autowired
AppRepository appRepository;
@Before
public void setUp() throws Exception {
App app = new App();
app.setAppId("testId");
appRepository.save(app);
}
@Test
public void testFindFirstByAppId() {
assertNotNull(appRepository.findFirstByAppId("testId"));
}
}
Run Code Online (Sandbox Code Playgroud)
封装结构 …
EntityScan类已从SpringBoot 1.5.0-SNAPSHOT中删除,当我更改为1.3.0-SNAPSHOT版本时,EntityScan存在.
我必须添加另一个依赖使用EntityScan与SpringBoot 1.5.0-SNAPSHOT?
我正在使用Spring Boot应用程序尝试与手动数据源连接,当运行项目时出现异常:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountController': Unsatisfied dependency expressed through field 'accountService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountServiceImpl': Unsatisfied dependency expressed through field 'accountDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountDao': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.springstudy.demo.model.Account
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:586) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE] …Run Code Online (Sandbox Code Playgroud)