我創建了一個存儲庫,但是當我調用我的存儲庫時,它每次都會給出一個NullPointerException。有人可以幫我弄清楚爲什麼?CrudRepository上的NullPointerException
我的倉庫
@Repository
public interface WorkflowObjectRepository extends CrudRepository<WorkflowObject, String> {
@Override
WorkflowObject findOne(String id);
@Override
void delete(WorkflowObject workflowObject);
@Override
void delete(String id);
@Override
WorkflowObject save(WorkflowObject workflowObject);
}
我的對象
@Data
@Entity
@Table(name = "workflowobject")
public class WorkflowObject {
@GeneratedValue
@Column(name="id")
private String id;
@Column(name = "state_name")
private String stateName;
}
我的測試
public class Test {
@Autowired
static WorkflowObjectRepository subject;
public static void main(String[] args) {
final WorkflowObject obj = new WorkflowObject();
obj.setId("maha");
obj.setStateName("test");
subject.findOne("maha");
}
}
application.properties
spring.datasource.url=jdbc:postgresql://localhost:5432/vtr?
autoReconnect=true
spring.datasource.username=vtr
spring.datasource.password=vtr
可能重複的[什麼是空指針異常,怎麼解決呢?(http://stackoverflow.com/questions/218384/what-is -a-nullpointerexception-and-how-do-i-fix-it) –
你能提供堆棧跟蹤嗎? –