IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JPA Java Discussion :

comment configurer correctement mon projet avec xampp


Sujet :

JPA Java

  1. #1
    Membre confirmé

    Profil pro
    Inscrit en
    Août 2008
    Messages
    1 191
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 1 191
    Points : 595
    Points
    595
    Par défaut comment configurer correctement mon projet avec xampp
    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:

    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 le fichier application.proprietes:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    spring.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
    voici l'erreur que j'ai:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    Description:
    Field contactRepository in mondomaine.fr.start.DemoApplication required a bean of type 'mondomaine.fr.dao.ContactRepository' that could not be found.
    mon fichier est configuration est t'il bon ?
    faut t'il faire quelque chose dans xampp ? (j'ai lancer mysql + tomcat)

    merci d'avance pour la réponse

  2. #2
    Membre confirmé

    Profil pro
    Inscrit en
    Août 2008
    Messages
    1 191
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 1 191
    Points : 595
    Points
    595
    Par défaut
    J'ai réussi à faire fonctionner et ajouter la table contact,
    j'ai mis toutes mes fichier à la même racine start et supprimer le dossier dao, entities.
    Auriez vous un idée de la cause ?

  3. #3
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    Salut,
    peux tu nous montrer la structure du repertoire de ton Projet.
    Est ce que le fichier qu´il demande existe.

    Eric

Discussions similaires

  1. Réponses: 1
    Dernier message: 17/10/2018, 16h03
  2. Réponses: 2
    Dernier message: 18/02/2009, 11h11
  3. Réponses: 9
    Dernier message: 10/01/2007, 09h04
  4. Réponses: 6
    Dernier message: 18/08/2006, 10h51
  5. Comment compiller mon projet avec Dev C++
    Par Micheal1221 dans le forum C++Builder
    Réponses: 2
    Dernier message: 05/07/2006, 12h38

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo