|
43 / 2 / 0
Регистрация: 08.02.2014
Сообщений: 37
|
||||||
Autowire в Spring конструкторе07.07.2015, 18:30. Показов 2246. Ответов 4
Метки нет (Все метки)
Ошибка прилагается. Кликните здесь для просмотра всего текста
июл 07, 2015 6:22:37 PM org.springframework.context.support.Clas sPathXmlApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.Clas sPathXmlApplicationContext@6267c3bb: startup date [Tue Jul 07 18:22:37 EEST 2015]; root of context hierarchy июл 07, 2015 6:22:37 PM org.springframework.beans.factory.xml.Xm lBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [META-INF/spring/copy-paste-context.xml] июл 07, 2015 6:22:37 PM org.springframework.context.support.Clas sPathXmlApplicationContext refresh WARNING: Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.BeanCr eationException: Error creating bean with name 'users' defined in file [C:\Users\alex\Documents\workspace-sts-3.6.4.RELEASE\CopyPaste\bin\org\alex\Use rs.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiat ionException: Failed to instantiate [org.alex.Users$$EnhancerBySpringCGLIB$$f 27c4379]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.alex.Users$$EnhancerBySpringCGLIB$$f 27c4379.<init>() at org.springframework.beans.factory.suppor t.AbstractAutowireCapableBeanFactory.ins tantiateBean(AbstractAutowireCapableBean Factory.java:1101) at org.springframework.beans.factory.suppor t.AbstractAutowireCapableBeanFactory.cre ateBeanInstance(AbstractAutowireCapableB eanFactory.java:1046) at org.springframework.beans.factory.suppor t.AbstractAutowireCapableBeanFactory.doC reateBean(AbstractAutowireCapableBeanFac tory.java:504) at org.springframework.beans.factory.suppor t.AbstractAutowireCapableBeanFactory.cre ateBean(AbstractAutowireCapableBeanFacto ry.java:476) at org.springframework.beans.factory.suppor t.AbstractBeanFactory$1.getObject(Abstra ctBeanFactory.java:303) at org.springframework.beans.factory.suppor t.DefaultSingletonBeanRegistry.getSingle ton(DefaultSingletonBeanRegistry.java:23 0) at org.springframework.beans.factory.suppor t.AbstractBeanFactory.doGetBean(Abstract BeanFactory.java:299) at org.springframework.beans.factory.suppor t.AbstractBeanFactory.getBean(AbstractBe anFactory.java:194) at org.springframework.beans.factory.suppor t.DefaultListableBeanFactory.preInstanti ateSingletons(DefaultListableBeanFactory .java:755) at org.springframework.context.support.Abst ractApplicationContext.finishBeanFactory Initialization(AbstractApplicationContex t.java:757) at org.springframework.context.support.Abst ractApplicationContext.refresh(AbstractA pplicationContext.java:480) at org.springframework.context.support.Clas sPathXmlApplicationContext.<init>(ClassP athXmlApplicationContext.java:139) at org.springframework.context.support.Clas sPathXmlApplicationContext.<init>(ClassP athXmlApplicationContext.java:83) at org.alex.CopyPaste.main(CopyPaste.java:2 8) Caused by: org.springframework.beans.BeanInstantiat ionException: Failed to instantiate [org.alex.Users$$EnhancerBySpringCGLIB$$f 27c4379]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.alex.Users$$EnhancerBySpringCGLIB$$f 27c4379.<init>() at org.springframework.beans.factory.suppor t.SimpleInstantiationStrategy.instantiat e(SimpleInstantiationStrategy.java:85) at org.springframework.beans.factory.suppor t.AbstractAutowireCapableBeanFactory.ins tantiateBean(AbstractAutowireCapableBean Factory.java:1094) ... 13 more Caused by: java.lang.NoSuchMethodException: org.alex.Users$$EnhancerBySpringCGLIB$$f 27c4379.<init>() at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.getDeclaredConstructor(U nknown Source) at org.springframework.beans.factory.suppor t.SimpleInstantiationStrategy.instantiat e(SimpleInstantiationStrategy.java:80) ... 14 more Exception in thread "main" org.springframework.beans.factory.BeanCr eationException: Error creating bean with name 'users' defined in file [C:\Users\alex\Documents\workspace-sts-3.6.4.RELEASE\CopyPaste\bin\org\alex\Use rs.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiat ionException: Failed to instantiate [org.alex.Users$$EnhancerBySpringCGLIB$$f 27c4379]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.alex.Users$$EnhancerBySpringCGLIB$$f 27c4379.<init>() at org.springframework.beans.factory.suppor t.AbstractAutowireCapableBeanFactory.ins tantiateBean(AbstractAutowireCapableBean Factory.java:1101) at org.springframework.beans.factory.suppor t.AbstractAutowireCapableBeanFactory.cre ateBeanInstance(AbstractAutowireCapableB eanFactory.java:1046) at org.springframework.beans.factory.suppor t.AbstractAutowireCapableBeanFactory.doC reateBean(AbstractAutowireCapableBeanFac tory.java:504) at org.springframework.beans.factory.suppor t.AbstractAutowireCapableBeanFactory.cre ateBean(AbstractAutowireCapableBeanFacto ry.java:476) at org.springframework.beans.factory.suppor t.AbstractBeanFactory$1.getObject(Abstra ctBeanFactory.java:303) at org.springframework.beans.factory.suppor t.DefaultSingletonBeanRegistry.getSingle ton(DefaultSingletonBeanRegistry.java:23 0) at org.springframework.beans.factory.suppor t.AbstractBeanFactory.doGetBean(Abstract BeanFactory.java:299) at org.springframework.beans.factory.suppor t.AbstractBeanFactory.getBean(AbstractBe anFactory.java:194) at org.springframework.beans.factory.suppor t.DefaultListableBeanFactory.preInstanti ateSingletons(DefaultListableBeanFactory .java:755) at org.springframework.context.support.Abst ractApplicationContext.finishBeanFactory Initialization(AbstractApplicationContex t.java:757) at org.springframework.context.support.Abst ractApplicationContext.refresh(AbstractA pplicationContext.java:480) at org.springframework.context.support.Clas sPathXmlApplicationContext.<init>(ClassP athXmlApplicationContext.java:139) at org.springframework.context.support.Clas sPathXmlApplicationContext.<init>(ClassP athXmlApplicationContext.java:83) at org.alex.CopyPaste.main(CopyPaste.java:2 8) Caused by: org.springframework.beans.BeanInstantiat ionException: Failed to instantiate [org.alex.Users$$EnhancerBySpringCGLIB$$f 27c4379]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.alex.Users$$EnhancerBySpringCGLIB$$f 27c4379.<init>() at org.springframework.beans.factory.suppor t.SimpleInstantiationStrategy.instantiat e(SimpleInstantiationStrategy.java:85) at org.springframework.beans.factory.suppor t.AbstractAutowireCapableBeanFactory.ins tantiateBean(AbstractAutowireCapableBean Factory.java:1094) ... 13 more Caused by: java.lang.NoSuchMethodException: org.alex.Users$$EnhancerBySpringCGLIB$$f 27c4379.<init>() at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.getDeclaredConstructor(U nknown Source) at org.springframework.beans.factory.suppor t.SimpleInstantiationStrategy.instantiat e(SimpleInstantiationStrategy.java:80) ... 14 more
0
|
||||||
| 07.07.2015, 18:30 | |
|
Ответы с готовыми решениями:
4
Spring @Autowire and @PreAuthorize not working properly
Spring MVC. 404 ошибка при включении Spring Data JPA в проект |
|
40 / 40 / 20
Регистрация: 14.05.2015
Сообщений: 116
|
|
| 08.07.2015, 08:45 | |
|
0
|
|
|
43 / 2 / 0
Регистрация: 08.02.2014
Сообщений: 37
|
|
| 08.07.2015, 11:01 [ТС] | |
|
Во всех гайдах пишут что нужен дэфолтный конструктор, это может быть конструктор без аргументов ИЛИ autowired конструктор с аргументами, я создал конструктор и добавил аннотацию autowired, после этого должно работать, но не работает, почему?
0
|
|
|
40 / 40 / 20
Регистрация: 14.05.2015
Сообщений: 116
|
||||||
| 08.07.2015, 12:31 | ||||||
Сообщение было отмечено Damians как решение
Решение
непонятно зачем вы @Service класс сделали @Configuration? Или @Configuration сервисом? В конфигурационных классах не должно быть бизнес логики, вы просто передаёте его при старте приложения в AnnotationConfigApplicationContext и всё.
Если Environment вам нужен именно в конфигурации, вот пример из доков спринга:
0
|
||||||
|
43 / 2 / 0
Регистрация: 08.02.2014
Сообщений: 37
|
|
| 08.07.2015, 13:03 [ТС] | |
|
действительно без аннотации configuration все заработало, я видимо не до конца с аннотациями разобрался, спасибо за помощь
0
|
|
| 08.07.2015, 13:03 | |
|
Помогаю со студенческими работами здесь
5
Перевод проекта из Spring Maven в обычный Spring MVC задания по spring core и spring mvc для новичков Spring: а как вы разрешаете зависимости для spring ? Jetty embedded + Spring MVC + Spring Security Spring Framework - запуск примеров Spring Искать еще темы с ответами Или воспользуйтесь поиском по форуму: |
|
Новые блоги и статьи
|
|||
|
Знаешь почему 90% людей редко бывают счастливыми?
kumehtar 14.04.2026
Потому что они ждут. Ждут выходных, ждут отпуска, ждут удачного момента. . .
а удачный момент так и не приходит.
|
Фиксация колонок в отчете СКД
Maks 14.04.2026
Фиксация колонок в СКД отчета типа Таблица.
Задача: зафиксировать три левых колонки в отчете.
Процедура ПриКомпоновкеРезультата(ДокументРезультат, ДанныеРасшифровки, СтандартнаяОбработка)
/ / . . .
|
Настройки VS Code
Loafer 13.04.2026
{
"cmake. configureOnOpen": false,
"diffEditor. ignoreTrimWhitespace": true,
"editor. guides. bracketPairs": "active",
"extensions. ignoreRecommendations": true,
. . .
|
Оптимизация кода на разграничение прав доступа к элементам формы
Maks 13.04.2026
Алгоритм из решения ниже реализован на нетиповом документе, разработанного в конфигурации КА2.
Задачи, как таковой, поставлено не было, проделанное ниже исключительно моя инициатива.
Было так:. . .
|
|
Контроль заполнения и очистка дат в зависимости от значения перечислений
Maks 12.04.2026
Алгоритм из решения ниже реализован на примере нетипового документа "ПланированиеПерсонала", разработанного в конфигурации КА2.
Задача: реализовать контроль корректности заполнения дат назначения. . .
|
Архитектура слоя интернета для сервера-слоя.
Hrethgir 11.04.2026
В продолжение https:/ / www. cyberforum. ru/ blogs/ 223907/ 10860. html
Знаешь что я подумал? Раз мы все источники пишем в голове ветки, то ничего не мешает добавить в голову такой источник, который сам. . .
|
Подстановка значения реквизита справочника в табличную часть документа
Maks 10.04.2026
Алгоритм из решения ниже реализован на примере нетипового документа "ПланированиеПерсонала", разработанного в конфигурации КА2.
Задача: при выборе сотрудника (справочник Сотрудники) в ТЧ документа. . .
|
Очистка реквизитов документа при копировании
Maks 09.04.2026
Алгоритм из решения ниже применим как для типовых, так и для нетиповых документов на самых различных конфигурациях.
Задача: при копировании документа очищать определенные реквизиты и табличную. . .
|