Я получаю следующую ошибку:
Причина: org.springframework.beans.factory.BeanCreationException: Ошибка создания компонента с именем 'profileSessionFactory', определенного в ресурсе пути к классу [config-beans.xml]: сбой вызова метода init;вложенное исключение - java.lang.NoClassDefFoundError: javax / xml / bind / JAXBException в org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAeBeBeBeBB)doCreateBean (AbstractAutowireCapableBeanFactory.java:579) в org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:501) в org.springframework.beans.factory.support.AbstractBeanFactory.lambda $ doGetBean $ 0 (AbstractBeanFactory.java: 317) в org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:228) в org.springframework.beans.factory.support.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199) в org.springframework.beans.factory.config.DependencyDeскрипт1065) at org.springframework..boot.spi.XmlMappingBinderAccess. (XmlMappingBinderAccess.java:43) по адресу org.hibernate.boot.MetadataSources. (MetadataSources.java:87) по адресу org.springframework.orm.hibernate5.LocalSessionFactoryBean.avaFactoryBean.jav.dll (38)org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet (LocalSessionFactoryBean.java:423) в org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods (AbstractAutowireCapableBeanFactory.java:1761) в org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory..JAXBException at org.apache.catalina.loader.WebappClassLoaderBase.loadClass (WebappClassLoaderBase.java:1308) в org.apache.catalina.loader.WebappClassLoaderBase.loadClass (WebappClassLoaderBase.java 100) 100* Вот мой файл pom: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>project.web</groupId> <artifactId>start</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>start Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.target>1.6</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.version>5.0.5.RELEASE</spring.version> <hibernate.version>5.2.17.Final</hibernate.version> <c3p0.version>0.9.5.2</c3p0.version> <hibernate.validator>5.4.1.Final</hibernate.validator> <jstl.version>1.2.1</jstl.version> <tld.version>1.1.2</tld.version> <junit.version>4.12</junit.version> <servlet.version>3.1.0</servlet.version> <servlet.version>3.0.1</servlet.version> <mysql.connector.version>5.1.9</mysql.connector.version> </properties> <dependencies> <!-- Junit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <!--Servlet-Api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>${servlet.version}</version> <scope>provided</scope> </dependency> <!-- Spring Framework --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4.5</version> </dependency> <!-- Hibernate dependencies --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>${c3p0.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>${hibernate.validator}</version> </dependency> <!-- JSTL Dependency --> <dependency> <groupId>javax.servlet.jsp.jstl</groupId> <artifactId>javax.servlet.jsp.jstl-api</artifactId> <version>${jstl.version}</version> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>${tld.version}</version> </dependency> <!-- Servlet API --> <!-- MySQL database driver --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.connector.version}</version> </dependency> <!-- Rabbit dependencies --> <dependency> <groupId>org.springframework.amqp</groupId> <artifactId>spring-rabbit</artifactId> <version>1.7.4.RELEASE</version> </dependency> <dependency> <groupId>com.rabbitmq</groupId> <artifactId>amqp-client</artifactId> <version>4.0.0</version> </dependency> </dependencies> <build> <finalName>start</finalName> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.1</version> <configuration> <server>myserver</server> <url>http://localhost:8080/manager/text</url> </configuration> </plugin> </plugins> </build> А вот мой файл определения бобов: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:rabbit="http://www.springframework.org/schema/rabbit" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd"> <context:component-scan base-package="start.web" /> <context:property-placeholder location="classpath:users.db.properties, classpath:users.rabbit.properties" /> <!-- data source --> <bean id="profileDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${datasource.driver}" /> <property name="url" value="${datasource.url}" /> <property name="username" value="${datasource.username}" /> <property name="password" value="${datasource.password}" /> </bean> <!-- Hibernate SessionFactory --> <bean id="profileSessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"> <property name="dataSource" ref="profileDataSource"></property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.id.new_generator_mappings">${hibernate.id.new_generator_mappings}</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.connection.zeroDateTimeBehavior">convertToNull</prop> </props> </property> <property name="packagesToScan" value="start.web.model.registration"></property> </bean> <!-- The transaction manager --> <tx:annotation-driven transaction-manager="transactionManager" /> <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager"> <property name="sessionFactory" ref="profileSessionFactory" /> </bean> <!-- Rabbit connections beans --> <rabbit:connection-factory id="emailAccountConnectionFactory" host="${users.host}"/> <rabbit:template id="amqpTemplate" connection-factory="emailAccountConnectionFactory" exchange="${users.account.exchange}" routing-key="${users.account.routingKey}"/> <!-- <rabbit:admin connection-factory="emailAccountConnectionFactory" />--> <rabbit:queue id="emailAccount" name="${users.account.queue.name}"/> <rabbit:direct-exchange name="${users.account.exchange}"> <rabbit:bindings> <rabbit:binding queue="emailAccount" key="${users.account.routingKey}" /> </rabbit:bindings> </rabbit:direct-exchange> <rabbit:listener-container connection-factory="emailAccountConnectionFactory" acknowledge="none"> <rabbit:listener ref="emailAccountAckListener" queue-names="${users.account.queue.name}" /> </rabbit:listener-container> </beans> Я читал в предыдущих постах, что спящийи весенние версии могут быть несовместимы, что может привести к этой проблеме, но я не уверен, что является верной версией совместимости.Я использую Spring 5.0.5. Release и Hibernate 5.2.17.Final.Пожалуйста, дайте мне знать, если есть подходящий обходной путь для этого
Причина: org.springframework.beans.factory.BeanCreationException: Ошибка создания компонента с именем 'profileSessionFactory', определенного в ресурсе пути к классу [config-beans.xml]: сбой вызова метода init;вложенное исключение - java.lang.NoClassDefFoundError: javax / xml / bind / JAXBException в org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean (AbstractAeBeBeBeBB)doCreateBean (AbstractAutowireCapableBeanFactory.java:579) в org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:501) в org.springframework.beans.factory.support.AbstractBeanFactory.lambda $ doGetBean $ 0 (AbstractBeanFactory.java: 317) в org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:228) в org.springframework.beans.factory.support.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:199) в org.springframework.beans.factory.config.DependencyDeскрипт1065) at org.springframework..boot.spi.XmlMappingBinderAccess. (XmlMappingBinderAccess.java:43) по адресу org.hibernate.boot.MetadataSources. (MetadataSources.java:87) по адресу org.springframework.orm.hibernate5.LocalSessionFactoryBean.avaFactoryBean.jav.dll (38)org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet (LocalSessionFactoryBean.java:423) в org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods (AbstractAutowireCapableBeanFactory.java:1761) в org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory..JAXBException at org.apache.catalina.loader.WebappClassLoaderBase.loadClass (WebappClassLoaderBase.java:1308) в org.apache.catalina.loader.WebappClassLoaderBase.loadClass (WebappClassLoaderBase.java 100) 100*
Вот мой файл pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>project.web</groupId> <artifactId>start</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>start Maven Webapp</name> <url>http://maven.apache.org</url> <properties> <maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.target>1.6</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <spring.version>5.0.5.RELEASE</spring.version> <hibernate.version>5.2.17.Final</hibernate.version> <c3p0.version>0.9.5.2</c3p0.version> <hibernate.validator>5.4.1.Final</hibernate.validator> <jstl.version>1.2.1</jstl.version> <tld.version>1.1.2</tld.version> <junit.version>4.12</junit.version> <servlet.version>3.1.0</servlet.version> <servlet.version>3.0.1</servlet.version> <mysql.connector.version>5.1.9</mysql.connector.version> </properties> <dependencies> <!-- Junit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <!--Servlet-Api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>${servlet.version}</version> <scope>provided</scope> </dependency> <!-- Spring Framework --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4.5</version> </dependency> <!-- Hibernate dependencies --> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernate.version}</version> </dependency> <dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>${c3p0.version}</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>${hibernate.validator}</version> </dependency> <!-- JSTL Dependency --> <dependency> <groupId>javax.servlet.jsp.jstl</groupId> <artifactId>javax.servlet.jsp.jstl-api</artifactId> <version>${jstl.version}</version> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>${tld.version}</version> </dependency> <!-- Servlet API --> <!-- MySQL database driver --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.connector.version}</version> </dependency> <!-- Rabbit dependencies --> <dependency> <groupId>org.springframework.amqp</groupId> <artifactId>spring-rabbit</artifactId> <version>1.7.4.RELEASE</version> </dependency> <dependency> <groupId>com.rabbitmq</groupId> <artifactId>amqp-client</artifactId> <version>4.0.0</version> </dependency> </dependencies> <build> <finalName>start</finalName> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.1</version> <configuration> <server>myserver</server> <url>http://localhost:8080/manager/text</url> </configuration> </plugin> </plugins> </build>
А вот мой файл определения бобов:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:rabbit="http://www.springframework.org/schema/rabbit" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd"> <context:component-scan base-package="start.web" /> <context:property-placeholder location="classpath:users.db.properties, classpath:users.rabbit.properties" /> <!-- data source --> <bean id="profileDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${datasource.driver}" /> <property name="url" value="${datasource.url}" /> <property name="username" value="${datasource.username}" /> <property name="password" value="${datasource.password}" /> </bean> <!-- Hibernate SessionFactory --> <bean id="profileSessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"> <property name="dataSource" ref="profileDataSource"></property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.id.new_generator_mappings">${hibernate.id.new_generator_mappings}</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.connection.zeroDateTimeBehavior">convertToNull</prop> </props> </property> <property name="packagesToScan" value="start.web.model.registration"></property> </bean> <!-- The transaction manager --> <tx:annotation-driven transaction-manager="transactionManager" /> <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager"> <property name="sessionFactory" ref="profileSessionFactory" /> </bean> <!-- Rabbit connections beans --> <rabbit:connection-factory id="emailAccountConnectionFactory" host="${users.host}"/> <rabbit:template id="amqpTemplate" connection-factory="emailAccountConnectionFactory" exchange="${users.account.exchange}" routing-key="${users.account.routingKey}"/> <!-- <rabbit:admin connection-factory="emailAccountConnectionFactory" />--> <rabbit:queue id="emailAccount" name="${users.account.queue.name}"/> <rabbit:direct-exchange name="${users.account.exchange}"> <rabbit:bindings> <rabbit:binding queue="emailAccount" key="${users.account.routingKey}" /> </rabbit:bindings> </rabbit:direct-exchange> <rabbit:listener-container connection-factory="emailAccountConnectionFactory" acknowledge="none"> <rabbit:listener ref="emailAccountAckListener" queue-names="${users.account.queue.name}" /> </rabbit:listener-container> </beans>
Я читал в предыдущих постах, что спящийи весенние версии могут быть несовместимы, что может привести к этой проблеме, но я не уверен, что является верной версией совместимости.Я использую Spring 5.0.5. Release и Hibernate 5.2.17.Final.Пожалуйста, дайте мне знать, если есть подходящий обходной путь для этого
Можете ли вы попробовать добавить следующую зависимость в ваш pom?
<dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.2.6</version> </dependency>