我正面临一个错误,告知自动连接的依赖项失败。我尝试了所有我能做的事情,并检查了很多论坛和stackoverflow,但我无法弄清楚它出了什么问题。
我附上了包括stacktrace在内的所有代码。
堆栈跟踪:
<Dec 22, 2016, 10:25:59,412 AM EST> <Error> <org.springframework.web.context.ContextLoader> <BEA-000000> <Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'homeController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.passwordmanager.service.LoginService com.passwordmanager.myapp.HomeController.loginService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.passwordmanager.dao.ILoginDAO com.passwordmanager.service.LoginService.iLoginDAO; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.passwordmanager.service.LoginService com.passwordmanager.myapp.HomeController.loginService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.passwordmanager.dao.ILoginDAO com.passwordmanager.service.LoginService.iLoginDAO; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.passwordmanager.dao.ILoginDAO com.passwordmanager.service.LoginService.iLoginDAO; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.passwordmanager.dao.ILoginDAO com.passwordmanager.service.LoginService.iLoginDAO; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:924)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:793)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
Truncated. see log file for complete stacktrace
>
<Dec 22, 2016, 10:25:59,436 AM EST> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'homeController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.passwordmanager.service.LoginService com.passwordmanager.myapp.HomeController.loginService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.passwordmanager.dao.ILoginDAO com.passwordmanager.service.LoginService.iLoginDAO; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'homeController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.passwordmanager.service.LoginService com.passwordmanager.myapp.HomeController.loginService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.passwordmanager.dao.ILoginDAO com.passwordmanager.service.LoginService.iLoginDAO; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.passwordmanager.service.LoginService com.passwordmanager.myapp.HomeController.loginService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.passwordmanager.dao.ILoginDAO com.passwordmanager.service.LoginService.iLoginDAO; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.passwordmanager.dao.ILoginDAO com.passwordmanager.service.LoginService.iLoginDAO; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.passwordmanager.dao.ILoginDAO com.passwordmanager.service.LoginService.iLoginDAO; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:924)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:793)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
Truncated. see log file for complete stacktrace
>
<Dec 22, 2016, 10:25:59,466 AM EST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "261459827548032" for task "0" on [partition-name: DOMAIN]. Error is: "weblogic.application.ModuleException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}"
weblogic.application.ModuleException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:924)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:793)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
Truncated. see log file for complete stacktrace
>
<Dec 22, 2016, 10:25:59,470 AM EST> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 9 task for the application "PasswordManager_war_exploded" on [partition-name: DOMAIN].>
<Dec 22, 2016, 10:25:59,477 AM EST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application "PasswordManager_war_exploded".>
<Dec 22, 2016, 10:25:59,477 AM EST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}:org.springframework.beans.factory.NoSuchBeanDefinitionException:No matching bean of type [com.passwordmanager.dao.ILoginDAO] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:924)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:793)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
Truncated. see log file for complete stacktrace
servlet的context.xml中:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<context:annotation-config />
<!-- Enables the Spring MVC @Controller programming model -->
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<beans:bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<beans:property name="driverClassName" value="com.mysql.jdbc.Driver" />
<beans:property name="url" value="jdbc:mysql://localhost:3306/springdemo" />
<beans:property name="username" value="root" />
<beans:property name="password" value="root" />
</beans:bean>
<interceptors>
<beans:bean id="webContentInterceptor"
class="org.springframework.web.servlet.mvc.WebContentInterceptor">
<beans:property name="cacheSeconds" value="0" />
<beans:property name="useExpiresHeader" value="true" />
<beans:property name="useCacheControlHeader" value="true" />
<beans:property name="useCacheControlNoStore" value="true" />
</beans:bean>
</interceptors>
<context:component-scan base-package="com.passwordmanager.myapp" />
<context:component-scan base-package="com.passwordmanager.service" />
<context:component-scan base-package="com.passwordmanager.dao" />
<beans:bean id="encoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder">
<beans:constructor-arg value="12"></beans:constructor-arg>
</beans:bean>
<mvc:annotation-driven />
<tx:annotation-driven proxy-target-class="true" />
</beans:beans>
HomeController中:
@Controller
class HomeController {
@Autowired
LoginService loginService;
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
@RequestMapping(value = "/test", method = RequestMethod.GET)
public String indexPage(Locale locale, Model model) {
logger.info("Welcome home! The client locale is {}.", locale);
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formattedDate = dateFormat.format(date);
model.addAttribute("serverTime", formattedDate );
return "home";
}
@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView userLogin() {
ModelAndView model = new ModelAndView("login");
//model.addObject("userName", name);
return model;
}
@RequestMapping(value="/result", method = RequestMethod.GET)
public ModelAndView loginResult(@RequestParam Map<String,String> reqParms) {
//LoginDetails loginDetails = new LoginDetails(reqParms.get("userName"), reqParms.get("userPassword"));
String userName = reqParms.get("userName");
String userPasswd = reqParms.get("userPassword");
User user = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String name = user.getUsername();
if(name.isEmpty()){
ModelAndView model = new ModelAndView("login");
return model;
}
else{
LoginDetails result = loginService.findByUsername(userName, userPasswd);
if(result != null) {
System.out.println(result.getuserName());
ModelAndView model = new ModelAndView("loginResult");
model.addObject("userName", name);
return model;
} else{
ModelAndView model = new ModelAndView("login");
return model;
}
}
}
login服务:
@Service
public class LoginService {
@Autowired
private ILoginDAO iLoginDAO;
/*public LoginService(ILoginDAO iLoginDAO) {
// TODO Auto-generated constructor stub
this.iLoginDAO = iLoginDAO;
}*/
public LoginDetails findByUsername(String username, String userPasswd) {
return iLoginDAO.findByUsername(username, userPasswd);
}
}
ILoginDAO:
@Repository
public interface ILoginDAO extends CrudRepository<LoginDetails, Long> {
@Query(" from LoginDetails as o where o.userName=:username and o.password = :userPasswd")
LoginDetails findByUsername(String username, String userPasswd);
//boolean checkLoginDetails(String username, String password);
//boolean checkLoginDetails(String username, String password);
}
我找不到这个错误。有人可以帮我修理它。
答案 0 :(得分:0)
请在您的配置中添加以下内容
添加DENSE_RANK()
配置以扫描您的jpa:repositories
包
repository
如果您与<jpa:repositories base-package="com.passwordmanager.dao"/>
合作JpaRepository
,我建议您使用CrudRepository
代替ORM
。
如果是,请将JPA
更新为
ILoginDAO
您还可以在@Repository
public interface ILoginDAO extends JpaRepository<LoginDetails, Long> {
中添加package
个分隔的定义。
component-scan
相反,
<context:component-scan base-package="com.passwordmanager.myapp" />
<context:component-scan base-package="com.passwordmanager.service" />
<context:component-scan base-package="com.passwordmanager.dao" />
答案 1 :(得分:0)
经过大量研究后,我通过将entityManagerFactory,jpaVendorAdapter和transactionManager添加到我的servlet-context.xml来修复此问题
以下是为了使其正常工作而添加的代码
<beans:bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<beans:property name="dataSource" ref="dataSource" />
<beans:property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
<beans:property name="packagesToScan" value="com.vamsi.model" />
<beans:property name="jpaProperties">
<beans:props>
<beans:prop key="autoReconnect">true</beans:prop>
<beans:prop key="profileSQL">true</beans:prop>
<beans:prop key="characterEncoding">utf-8</beans:prop>
<beans:prop key="hibernate.hbm2ddl.auto">NONE</beans:prop>
</beans:props>
</beans:property>
</beans:bean>
<beans:bean id="jpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<beans:property name="database" value="MYSQL" />
<beans:property name="showSql" value="true" />
<beans:property name="generateDdl" value="true" />
<beans:property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
</beans:bean>
<beans:bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<beans:property name="entityManagerFactory" ref="entityManagerFactory" />
</beans:bean>
以上代码也可以用persistance.xml编写