我有一个存储库,注有@Repository
df.fillna('').applymap(lambda x: x if isinstance(x, str) else str(int(x))).agg('_'.join, axis=1)
Out[1927]:
0 _-1_27
1 _-1_42
2 _-1_67
3 _-1_95
4 91_CCMS_14638_91
5 DIP96__96
6 106_11694_106
dtype: object
我的控制器的一部分:
package com.jeppa.interfaces;
import com.jeppa.entities.User;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface UserRepository extends CrudRepository<User, String> {
User findByUserEmailIgnoreCase(String useremail);
}
最后,我的@SpringBootApplication:
package com.jeppa.controllers;
import com.jeppa.entities.ConfirmationToken;
import com.jeppa.entities.User;
import com.jeppa.interfaces.TokenRepository;
import com.jeppa.interfaces.UserRepository;
import com.jeppa.mail.EmailSenderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class UserAccountController {
@Autowired
private UserRepository userRepository;
@Autowired
private TokenRepository tokenRepository;
@Autowired
private EmailSenderService emailSenderService;
@RequestMapping(value = "/register", method = RequestMethod.GET)
public ModelAndView displayRegistration(ModelAndView modelAndView, User user){
modelAndView.addObject("user", user);
modelAndView.setViewName("register");
return modelAndView;
}
//////////////
而且我不断收到此错误
********************************应用程序无法启动
说明:
com.jeppa.controllers.UserAccountController中的字段userRepository 需要类型为“ com.jeppa.interfaces.UserRepository”的bean, 找不到。
注入点具有以下注释: -@ org.springframework.beans.factory.annotation.Autowired(required = true)
操作:
考虑定义类型为“ com.jeppa.interfaces.UserRepository”的bean 在您的配置中。
我在做什么错?这是我的项目结构: structure
答案 0 :(得分:0)
使用Spring Boot,通常应该依靠Spring Boot启动器来自动配置依赖项。如果是Spring Data,请添加:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
进入pom文件以自动配置Spring Data,而不是直接依赖Spring Data(spring-data-jpa
),这需要进一步的手动配置。
也不要忘记添加和配置实际的实现(h2,jdbc等)