Spring Boot:按用户名搜索返回null(Postgres)

时间:2018-01-06 20:53:31

标签: java postgresql spring-boot spring-data spring-data-rest

我试图检查用户对数据库的输入,但总是得到null返回(Spring Boot,Postgres)。我以为我的代码实际上并没有触及数据库。这是我的控制器,仓库,服务和服务impl。我不知道我是否遗漏了某些东西:

DSBInfoController.java

@RestController
@RequestMapping(value = "/DataSubmissionInfo")
public class DSBInfoController {

@Autowired
private DSBInfoService service;


private ProviderService pservice;

private ProviderRepo pr;




@Autowired
public Provider getProvider() {
    return provider;
}

public void setProvider(Provider provider) {
    this.provider = provider;
}


private Provider provider;


@RequestMapping(value ="/All", method = RequestMethod.POST, 
        produces = MediaType.APPLICATION_JSON_VALUE)
public void getAllInfo( @RequestBody String providername) {
    System.out.println("yo yo yo");
    System.out.println(  pservice.getByProviderName(providername));

}

ProviderRepo.java

public interface ProviderRepo extends CrudRepository<Provider, String> {


public Provider findByProvidername(String arg0);


}

ProviderService.java

ProviderService.java

import java.util.List;

import org.bellese.ehrbackend.beans.Provider;

public interface ProviderService {


public List<Provider> findAll();


public Provider getByProviderName(String arg0);


public <S extends Provider> List<S> save(Iterable<S> arg0);
}

providerServiceimpl.java

public class ProviderServiceImpl implements ProviderService {

@Autowired
private ProviderRepo repo;

@Override
public List<Provider> findAll() {
    // TODO Auto-generated method stub
    return null;
}

@Override
@Transactional(readOnly=true)
public Provider getByProviderName(String providername) {

    return repo.findByProvidername(providername);
}

@Override
public <S extends Provider> List<S> save(Iterable<S> arg0) {
    // TODO Auto-generated method stub
    return null;
}

}

我还是Spring Boot的新手。我跟着很多教程都没有用。请帮忙。

0 个答案:

没有答案