beans ne pas define ie настройка конфигурации приложения Spring Boot - PullRequest
0 голосов
/ 12 апреля 2020

Я пытаюсь создать веб-приложение с Spring Boot JPA
Но у меня проблема.
это мой код:
------ основной класс:

@SpringBootApplication
public class VotreBanqueApplication implements CommandLineRunner {

@Autowired
private ClientRepository clientReposiroty;
@Autowired
private CompteRepository compteRepository;
@Autowired
private IBanqueMetier banqueMetier;
@Autowired
private OperationRepository oper;
public static void main(String[] args) {
    SpringApplication.run(VotreBanqueApplication.class, args);
    //ClientRepository clientRepository = ctx.getBean(ClientRepository.class);

}
@Override
public void run(String... args) throws Exception {
Client c1 =clientReposiroty.save(new Client("Ougli", "oug.marouane@gmail.com"));
    Compte cp =compteRepository.save(new CompteCourant("c1", new Date(), 15000, c1, 6000));
Client c2 = clientReposiroty.save(new Client("Ougli","prorammer@ggg.vom"));
oper.save(new Versement(new Date(), 54000, cp));
oper.save(new Versement(new Date(), 540005, cp));
    banqueMetier.retirer("c1", 40);
}

класс обслуживания:

@Service

@ Transactional publi c Класс BanqueMetierImp реализует IBanqueMetier {

@Autowired
private CompteRepository compteRepository;

@Autowired
private OperationRepository operationRepository;

public BanqueMetierImp(CompteRepository compteRepository, OperationRepository operationRepository) {
    super();
    this.compteRepository = compteRepository;
    this.operationRepository = operationRepository;
}

public BanqueMetierImp() {
    super();
    // TODO Auto-generated constructor stub
}



@Override
public Compte consulterCompte(String codeCompte) {
    Compte compte = compteRepository.findOne(codeCompte);
    if(compte == null) throw new RuntimeException("Compte Introuvable! ");
    return compte;
}

@Override
public void verser(String codeCompte, double montant) {
    Compte compte = consulterCompte(codeCompte);
    Versement versement = new Versement(new Date(), montant, compte);
    operationRepository.save(versement);
    compte.setSolde(compte.getSolde()+montant);
    compteRepository.save(compte);

}

@Override
public void retirer(String codeCompte, double montant) {
    Compte compte = consulterCompte(codeCompte);
    double facilitesCaisse=0;
    if (compte instanceof CompteCourant)
        facilitesCaisse=((CompteCourant) compte).getDecouverte();
    if((facilitesCaisse + compte.getSolde())<montant)
        throw new RuntimeException("Le solde insuffisant !");
    Retrait retrait = new Retrait(new Date(), montant, compte);
    operationRepository.save(retrait);
    compte.setSolde(compte.getSolde()-montant);
    compteRepository.save(compte);

}

@Override
public void virement(String codeCompte1, String codeCompte2, double montant) {
    retirer(codeCompte1, montant);
    verser(codeCompte2, montant);

}

@Override
public Page<Operation> listOperation(String codeCompte, int page, int taille) {

    return operationRepository.listOperation(codeCompte, new PageRequest(page, taille));
    //return operationRepository. listOperation(codeCompte,PageRequest.of(page, taille));
}

}

public interface IBanqueMetier {

public Compte consulterCompte(String codeCompte);
public void verser(String codeCompte, double montant);
public void retirer(String codeCompte, double montant);
public void virement(String codeCompte1, String codeCompte2, double montant);
public Page<Operation> listOperation(String codeCompte, int page, int taille);

}

консольное сообщение:

 .   ____          _            __ _ _

/ \ / ' __ _ () _ __ __ _ \ \ \ \ (() _ | '_ |' | | ' / `| \ \ \ \ \ / ) | | ) | | | | | || ( | |)))) '| ____ | . | | | | | | __, | / / / / ========= | _ | ============== | ___ / = / / / _ / :: Spring Boot: : (v1.4.3.RELEASE)

2020-04-10 20: 47: 29.671 INFO 26300 --- [restartedMain] org.sid.VotreBanqueApplication: запуск приложения VotreBanque на USER-P C с PID 26300 (C: \ Users \ USER \ eclipse-workspace \ VotreBanque \ target \ классы, запущенные пользователем в C: \ Users \ USER \ eclipse-workspace \ VotreBanque) 2020-04-10 20: 47: 29.675 INFO 26300 --- [restartedMain] org.sid.VotreBanqueApplication: активный профиль не установлен, откат к профилям по умолчанию: по умолчанию 2020-04-10 20: 47: 30.158 INFO 26300 --- [restartedMain] ationConfigEmbeddedWebApplicationContext: обновление org.springframework.boot .context.embedded. AnnotationConfigEmbeddedWebApplicationContext@4273c5af: дата запуска [пт 10 апреля 20:47:30 WEST 2020]; root контекстной иерархии 2020-04-10 20: 47: 34.694 ИНФОРМАЦИЯ 26300 --- [restartedMain] trationDelegate $ BeanPostProcessorChecker: Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' типа [класс org.springframeworkt. annotation.ProxyTransactionManagementConfiguration $$ EnhancerBySpringCGLIB $$ 754be012] не может обрабатываться всеми BeanPostProcessors (например, не имеет права на автоматическое проксирование) 2020-04-10 20: 47: 35.726 ИНФО 26300 --- [restartedMain] sb c .etTomcatEmbeddedServletContainer: Tomcat инициализирован с портом (порциями): 8081 (http) 2020-04-10 20: 47: 35.747 INFO 26300 --- [restartedMain] o. apache .catalina.core.StandardService: Запуск службы Tomcat 2020-04-10 20: 47: 35.749 INFO 26300 --- [restartedMain] org. apache .catalina.core.StandardEngine: Запуск двигателя сервлета: Apache Tomcat / 8.5.6 2020-04-10 20:47 : 35.954 INFO 26300 --- [ost-startStop-1] oa c. c. C. [Tomcat]. [Localhost]. [/]: Инициализация вставки Spring ded WebApplicationContext 2020-04-10 20: 47: 35.954 INFO 26300 --- [ost-startStop-1] osweb.context.ContextLoader: Root WebApplicationContext: инициализация завершена за 5796 мс 2020-04-10 20: 47: 36.246 ИНФОРМАЦИЯ 26300 --- [ost-startStop-1] osbwservlet.ServletRegistrationBean: Отображение сервлета: 'dispatcherServlet' в [/] 2020-04-10 20: 47: 36.253 ИНФОРМАЦИЯ 26300 --- [ost-startStop-1] osbwservlet. FilterRegistrationBean: Фильтр отображения: 'characterEncodingFilter' на: [/ ] 2020-04-10 20: 47: 36.254 INFO 26300 --- [ost-startStop-1] osbwservlet.FilterRegistrationBean: Фильтр отображения: 'hiddenHttpMethodFilter' для: [/ ] 2020-04-10 20: 47: 36.254 INFO 26300 --- [ost-startStop-1] osbwservlet.FilterRegistrationBean: Фильтр отображения: 'httpPutFormContentFilter' на: [/ ] 2020-04- 10 20: 47: 36.254 INFO 26300 --- [ost-startStop-1] osbwservlet.FilterRegistrationBean: Фильтр отображения: 'requestContextFilter' на: [/ ] 2020-04-10 20: 47: 36.634 INFO 26300 - - [restartedMain] j.LocalContainerEntityManager FactoryBean: сборка контейнера JPA EntityManagerFactory для единицы сохраняемости 'default' 2020-04-10 20: 47: 36.662 INFO 26300 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper: HHH000204: обработка PersistenceUnitInfo [имя: по умолчанию ...] 2020-04-10 20: 47: 36.783 INFO 26300 --- [restartedMain] org.hibernate.Version: HHH000412: Hibernate Core {5.0.11.Final} 2020-04-10 20: 47: 36.785 INFO 26300 --- [restartedMain] org.hibernate.cfg. Среда: HHH000206: hibernate.properties не найден 2020-04-10 20: 47: 36.787 INFO 26300 --- [restartedMain] org.hibernate.cfg.Environment: HHH000021: Имя поставщика байт-кода: javassist 2020-04-10 20:47 : 36.869 ИНФОРМАЦИЯ 26300 --- [restartedMain] o.hibernate.annotations.common.Version: HCANN000001: Hibernate Общие комментарии {5.0.1.Final} 2020-04-10 20: 47: 37.822 ИНФО 26300 --- [restartedMain] org.hibernate.dialect.Dialect: HHH000400: Использование диалекта: org.hibernate.dialect.MySQL5Dialect 2020-04-10 20: 47: 39.253 INFO 26300 --- [restartedMain] org.hibernate.tool.hbm2ddl.SchemaUpdate: HHH000228: Выполнение обновления схемы hbm2ddl 2020-04-10 20: 47: 41.612 INFO 26300 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean: Инициализированный JPA EntityManagerFactory для единицы сохраняемости 'default' 2020-04-10 20: 47: 43.021 ПРЕДУПРЕЖДЕНИЕ 26300 --- [restartedMain] ationConfigEmbeddedWebApplicationContext: Обнаружено исключение во время инициализации контекста - отмена refre sh попытки: org.springframe work.beans.factory.UnsatisfiedDependencyException: Ошибка создания компонента с именем 'votreBanqueApplication': Неудовлетворенная зависимость, выраженная через поле 'banqueMetier'; Вложенное исключение - org.springframework.beans.factory.NoSuchBeanDefinitionException: не доступен квалифицирующий компонент типа 'ord.sid.metier.IBanqueMetier': ожидается, что по крайней мере 1 компонент будет квалифицирован как кандидат для автопроводки. Аннотации зависимостей: {@ org.springframework.beans.factory.annotation.Autowired (обязательно = true)} 2020-04-10 20: 47: 43.023 INFO 26300 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean: Закрытие JPA EntityManagerFactory для сохранения 'default' 2020-04-10 20: 47: 43.048 INFO 26300 --- [restartedMain] o. apache .catalina.core.StandardService: Остановка службы Tomcat 2020-04-10 20: 47: 43.139 INFO 26300 - - [restartedMain] utoConfigurationReportLoggingInitializer:

Ошибка запуска ApplicationContext. Для отображения отчета автоконфигурации перезапустите ваше приложение с включенной отладкой. 2020-04-10 20: 47: 43.841 ОШИБКА 26300 --- [restartedMain] osbdLoggingFailureAnalysisReporter:


Приложение не удалось запустить


Описание:

Поле banqueMetier в org.sid.VotreBanqueApplication требует bean-компонент типа 'ord.sid.metier.IBanqueMetier', который не может быть найден.

Действие:

Рассмотрим определение бина типа 'ord .sid.metier.IBanqueMetier 'в вашей конфигурации.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...