java - mvn dependency for repository.save() -
i struggling this. every time add main class in repository.save(customerdetails) error message. when click on error asked add dependency doesn't tell me dependency add.
how figure out?
here's class:
package com.example.customer.application; import com.example.customer.customerrepository.customerdetailrepository; import com.example.customer.model.customerdetails; import org.springframework.boot.autoconfigure.springbootapplication; import java.util.arraylist; import java.util.list; @springbootapplication public class accountapplication { public static void main(string[] args) { } private void name(customerdetailrepository repository) { list<customerdetails> cd = new arraylist<>(); cd.add(new customerdetails(1, "foo", "bar")); cd.add(new customerdetails(2, "foo1", "bar1")); customerdetails cdd = new customerdetails(1, "a", "b"); { } repository.save(customerdetails); error is. } }
here's main class:
package com.example.customer.model; import com.example.customer.customerapplication; import org.springframework.boot.autoconfigure.domain.entityscan; import javax.annotation.generated; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.generationtype; @entity public class customerdetails { private long id; private string name; private string address; public customerdetails() { } public customerdetails(long id, string name, string address) { this.id = id; this.name = name; this.address = address; } public long getid() { return id; } public void setid(long id) { this.id = id; } public string getname() { return name; } public void setname(string name) { this.name = name; } public string getaddress() { return address; } public void setaddress(string address) { this.address = address; } }
here's controller code
package com.example.customer.controller; import com.example.customer.model.customerdetails; import com.sun.org.apache.bcel.internal.generic.return; import org.springframework.boot.autoconfigure.domain.entityscan; import org.springframework.stereotype.controller; import org.springframework.stereotype.repository; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.bind.annotation.restcontroller; import javax.annotation.generated; import java.util.arraylist; import java.util.list; @restcontroller public class customerapplication { @requestmapping(method = requestmethod.get, path = "/findcustomer") public customerdetails createnewcustomerrecord() { return new customerdetails(1, "sarah", "88 strong road"); } }
can help? know dependency can add fix bug?
Comments
Post a Comment