spring - how to fix the CrudRepository.save(java.lang.Object) is no accessor method in springboot? -
im reffering springboot
tutorial , im using spring data
in project, im trying add data database
. using following .
bt when im trying error saying
invoked method public abstract java.lang.object org.springframework.data.repository.crudrepository.save(java.lang.object) no accessor method!
here code ,
//my controller @requestmapping("/mode") public string showproducts(moderepository repository){ mode m = new mode(); m.setseats(2); repository.save(m); //this error getting return "product"; } //implementing crud mode repository @repository public interface moderepository extends crudrepository<mode, long> { } //my mode class @entity @table(name="mode") public class mode implements serializable { private static final long serialversionuid = 1l; @id @generatedvalue(strategy=generationtype.auto) @column(unique=true, nullable=false) private int idmode; @column(nullable=false) private int seats; //assume there getters , setters }
im new springboot
, can tellme doing wrong, appreciate if provide me link know springdata
other spring documentation
change controller code moderepository private autowired field.
@autowired //don't forget setter private moderepository repository; @requestmapping("/mode") public string showproducts(){ mode m = new mode(); m.setseats(2); repository.save(m); //this error getting return "product"; }
Comments
Post a Comment