Код: Выделить всё
@SpringBootApplication
@EnableAutoConfiguration
@EnableJpaRepositories
@RestController
public class Javatest3Application {
//---VARIABLES---
private JavatestService service_handler = new JavatestService();
//---PUBLIC---
public static void main(String[] args) {
SpringApplication.run(Javatest3Application.class, args);
}
@PostMapping("/login")
public ResponseEntity Login(@RequestBody Map json_map) {
//>>Read json_map for account_name and account_pwd
//Ask Service layer to log user in
Long session_id = this.service_handler.OpenSession(account_name, account_pwd);
//>>Construct response, blah blah...
}
}
Код: Выделить всё
@Service
public class JavatestService {
//---VARIABLES---
@Autowired
private JavatestRepository repo;
//---PUBLIC---
public JavatestService() {}
public Long OpenSession(String in_name, String in_pwd) {
//Call database for credentials
List user_listings = this.repo.findAll(); //>Go though list, blah blah...
}
}
Код: Выделить всё
@Repository
public interface JavatestRepository extends JpaRepository {
//List findAll();
Подробнее здесь: [url]https://stackoverflow.com/questions/67442147/spring-boot-jparepository-postgresql-why-is-repository-interface-is-not-inst[/url]