Bonjour, je souhaite testé la création d'une table membre avec spring boot + jpa, comme je débute je suis perdu car spring boot ne créer pas de membre.
j' utilise xampp mysql comme base de donnée, visual studio comme ide, je suis en local avec windows 10.
j'ai cette interface:
Code java : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 package mondomaine.fr.dao; import org.springframework.data.jpa.repository.JpaRepository; import mondomaine.fr.entities.Contact; public interface ContactRepository extends JpaRepository<Contact,Long>{ }
voici la classe démo de test:
voici le fichier application.proprietes:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package mondomaine.fr.start; import java.text.DateFormat; import java.text.SimpleDateFormat; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import mondomaine.fr.dao.ContactRepository; import mondomaine.entities.Contact; @SpringBootApplication public class DemoApplication implements CommandLineRunner{ @Autowired private ContactRepository contactRepository; public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } @Override public void run(String... arg0) throws Exception { System.out.println("test visual studio spring"); DateFormat df=new SimpleDateFormat("dd/MM/yyyy"); contactRepository.save(new Contact("jean", "marchand", df.parse("01/01/2007"), "jean@free.fr", 1234)); contactRepository.save(new Contact("lea", "dupont", df.parse("01/01/1981"), "lea@sfr.fr", 5678)); contactRepository.findAll().forEach(c->{ System.out.println(c.getNom()); }); } }
voici l'erreur que j'ai:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7spring.datasource.url= jdbc:mysql://localhost:3306/membre?zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=UTC spring.datasource.username=root spring.datasource.password= spring.datasource.driverClassName= com.mysql.jdbc.Driver spring.jpa.hibernate.ddl-auto=update spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
mon fichier est configuration est t'il bon ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3Description: Field contactRepository in mondomaine.fr.start.DemoApplication required a bean of type 'mondomaine.fr.dao.ContactRepository' that could not be found.
faut t'il faire quelque chose dans xampp ? (j'ai lancer mysql + tomcat)
merci d'avance pour la réponse![]()
Partager