Я пытаюсь интегрировать Hibernate и Struts 2.
Это applicationContext.xml:
< pre class="lang-xml Prettyprint-override">
classpath:hibernate.cfg.xml
org.hibernate.cfg.AnnotationConfiguration
${jdbc.dialect}
true
У меня уже есть jdbc.properties и я сохраняю своего клиента в DAO:
CustomerDAO:
public class CustomerDAO {
@Autowired
private SessionFactory sessionFactory;
public void persistAuthor(Customer customer) {
sessionFactory.getCurrentSession().save(customer);
}
}
Это класс Entity:
@Table(name="customer")
@Entity
public class Customer {
@Id
@GeneratedValue
private Integer id;
private String name;
private String password;
public Integer getId() {
return id;
}
//Getter/Setters//
}
Это мой класс Action:
public class CustomerAction extends ActionSupport {
private static final Logger logger = Logger.getLogger(CustomerAction.class);
Customer customer;
CustomerDAO customerdao;
private Integer id;
private String name;
private String password;
//GETTERS/SETTERS//
@Action(value="/customer", results={
@Result(name="success",location="/customerSuccess.jsp"),
})
public String execute() throws Exception {
logger.debug("Hello");
customer.setId(getId());
customer.setName(getName());
customer.setPassword(getPassword());
customerdao.persistAuthor(customer);
return SUCCESS;
}
Однако мне отображается это исключение.
Исключение:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is
java.lang.IllegalStateException: AnnotationTransactionAttributeSource is only available on Java 1.5 and higher
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
Подробнее здесь: https://stackoverflow.com/questions/255 ... ce-is-only
Интеграция Struts 2 и Hibernate: AnnotationTransactionAttributeSource доступен только на Java 1.5 и выше. ⇐ JAVA
Программисты JAVA общаются здесь
1731236627
Anonymous
Я пытаюсь интегрировать Hibernate и Struts 2.
[b]Это applicationContext.xml:[/b]
< pre class="lang-xml Prettyprint-override">
classpath:hibernate.cfg.xml
org.hibernate.cfg.AnnotationConfiguration
${jdbc.dialect}
true
У меня уже есть jdbc.properties и я сохраняю своего клиента в DAO:
[b]CustomerDAO:[/b]
public class CustomerDAO {
@Autowired
private SessionFactory sessionFactory;
public void persistAuthor(Customer customer) {
sessionFactory.getCurrentSession().save(customer);
}
}
[b]Это класс Entity:[/b]
@Table(name="customer")
@Entity
public class Customer {
@Id
@GeneratedValue
private Integer id;
private String name;
private String password;
public Integer getId() {
return id;
}
//Getter/Setters//
}
[b]Это мой класс Action:[/b]
public class CustomerAction extends ActionSupport {
private static final Logger logger = Logger.getLogger(CustomerAction.class);
Customer customer;
CustomerDAO customerdao;
private Integer id;
private String name;
private String password;
//GETTERS/SETTERS//
@Action(value="/customer", results={
@Result(name="success",location="/customerSuccess.jsp"),
})
public String execute() throws Exception {
logger.debug("Hello");
customer.setId(getId());
customer.setName(getName());
customer.setPassword(getPassword());
customerdao.persistAuthor(customer);
return SUCCESS;
}
Однако мне отображается это исключение.
[b]Исключение:[/b]
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is
java.lang.IllegalStateException: AnnotationTransactionAttributeSource is only available on Java 1.5 and higher
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
Подробнее здесь: [url]https://stackoverflow.com/questions/25593893/integrating-struts-2-and-hibernate-annotationtransactionattributesource-is-only[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия