Я новичок в разработке Spring.Я пытался создать веб-приложение, используя Spring boot 2.0.6, но оно выдает мне следующую ошибку:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-10-27 22:58:02.226 ERROR 8536 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.RuntimeException: Driver com.mysql.jdbc.Driver claims to not accept jdbcUrl, jbdc:mysql://localhost:3306/dbutilisateur
Вот мой код:
Utilisateur.java (entity):
package org.sid.entities;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class Utilisateur implements Serializable {
@Id @GeneratedValue
private Long id;
private boolean is_asso;
private String ref_asso;
private String nom;
private String email;
private String adresse;
private String tel;
private String cin;
private Date dateInscription;
private Date derniereModification;
public Utilisateur(boolean is_asso, String ref_asso, String nom, String email, String adresse, String tel,
String cin, Date dateInscription, Date derniereModification) {
super();
this.is_asso = is_asso;
this.ref_asso = ref_asso;
this.nom = nom;
this.email = email;
this.adresse = adresse;
this.tel = tel;
this.cin = cin;
this.dateInscription = dateInscription;
this.derniereModification = derniereModification;
}
public Utilisateur() {
super();
// TODO Auto-generated constructor stub
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public boolean isIs_asso() {
return is_asso;
}
public void setIs_asso(boolean is_asso) {
this.is_asso = is_asso;
}
public String getRef_asso() {
return ref_asso;
}
public void setRef_asso(String ref_asso) {
this.ref_asso = ref_asso;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAdresse() {
return adresse;
}
public void setAdresse(String adresse) {
this.adresse = adresse;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public String getCin() {
return cin;
}
public void setCin(String cin) {
this.cin = cin;
}
public Date getDateInscription() {
return dateInscription;
}
public void setDateInscription(Date dateInscription) {
this.dateInscription = dateInscription;
}
public Date getDerniereModification() {
return derniereModification;
}
public void setDerniereModification(Date derniereModification) {
this.derniereModification = derniereModification;
}
}
UtilisateurRepository.java
package org.sid.dao;
import org.sid.entities.Utilisateur;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface UtilisateurRepository extends
JpaRepository<Utilisateur,Long> {
}
DemoApplication.java:
package org.sid;
import org.sid.dao.UtilisateurRepository;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import org.sid.entities.Utilisateur;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication implements CommandLineRunner {
@Autowired
private UtilisateurRepository utilisateurRepository;
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
// TODO Auto-generated method stub
DateFormat df=new SimpleDateFormat("dd/MM/yyyy");
utilisateurRepository.save(new Utilisateur(false,"111","oumaima","sfqs@qsfqs","2mars","09876","BK234",df.parse("12/12/2012"),df.parse("30/12/2012")));
utilisateurRepository.save(new Utilisateur(false,"222","ouma","ouma@qsfqs","3mars","09876","BK234",df.parse("13/12/2012"),df.parse("30/01/2012")));
utilisateurRepository.findAll().forEach(c->{System.out.println(c.getNom());});}}
и application.properties:
spring.datasource.url=jbdc:mysql://localhost:3306/dbutilisateur
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
Есть предложения по решению?Спасибо