2017-12-29 26 views
0

봄 부팅 응용 프로그램을 biulding 오전. 원하는 출력을 얻지 못합니다. 누구든지이 기본 응용 프로그램을 도울 수 있습니까? init 메소드의 호출이 실패봄 부팅 Jaxb 오류

org.springframework.beans.factory.BeanCreationException '의 EntityManagerFactory'는 클래스 패스 리소스에 정의 [조직/스프링 프레임 워크/부팅/자동 구성은/ORM/JPA/HibernateJpaAutoConfiguration.class] 이름을 가진 bean을 생성 오류 ; 상자의 예외가 java.lang.NoClassDefFoundError가 있습니다 : javax의/XML/바인드/JAXBException에

Topic.java

package com.example.demo.topics; 
    import javax.persistence.Entity; 
    import javax.persistence.Id; 

    @Entity 
    public class Topic { 


    @Id 
    String topicId; 
    String topicName; 
    String topicDescription; 

    public Topic() {} 

    public Topic(String topicId, String topicName, String topicDescription) { 
     super(); 
     this.topicId = topicId; 
     this.topicName = topicName; 
     this.topicDescription = topicDescription; 
    } 
    public String getTopicId() { 
     return topicId; 
    } 
    public void setTopicId(String topicId) { 
     this.topicId = topicId; 
    } 
    public String getTopicName() { 
     return topicName; 
    } 
    public void setTopicName(String topicName) { 
     this.topicName = topicName; 
    } 
    public String getTopicDescription() { 
     return topicDescription; 
    } 
    public void setTopicDescription(String topicDescription) { 
     this.topicDescription = topicDescription; 
    } 
} 

컨트롤러 클래스

package com.example.demo.topics; 

import java.util.List; 

import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.RequestMethod; 
import org.springframework.web.bind.annotation.RestController; 

@RestController 
public class TopicController { 

    @Autowired 
    TopicService topicService; 

    @RequestMapping("/") 
    private String getWelcome() { 
     return "Hello"; 
    } 

    @RequestMapping("/topics") 
    private List<Topic> getTopics() { 
     return topicService.getTopics(); 
    } 

    @RequestMapping("/topics/{id}") 
    private Topic getTopicById(String id) { 
     return topicService.getTopicbyId(id); 
    } 

    @RequestMapping(method=RequestMethod.POST, value="/topics/{id}") 
    private void putTopic(Topic topic) { 
     topicService.putTopic(topic); 
    } 

} 

저장소 클래스

package com.example.demo.topics; 

import org.springframework.data.repository.CrudRepository; 

public interface TopicRepository extends CrudRepository<Topic,String>{ 

} 

서비스 클래스

package com.example.demo.topics; 

import java.util.ArrayList; 
import java.util.List; 

import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.stereotype.Service; 

@Service 
public class TopicService { 

    @Autowired 
    private TopicRepository topicRepository; 



    public List<Topic> getTopics() { 
     List<Topic> topics= new ArrayList<Topic>(); 
     topicRepository.findAll().forEach(topics::add); 

     return topics; 
    } 

    public Topic getTopicbyId(String id) { 
     return topicRepository.findOne(id); 
    } 

    public void putTopic(Topic topic) { 
     topicRepository.save(topic); 
    } 





} 

의 pom.xml

http://maven.apache.org/xsd/maven-4.0.0.xsd "> 4.0.0

<groupId>com.example</groupId> 
<artifactId>springboottopics</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>jar</packaging> 

<name>springboottopics</name> 
<description>First Java Brains project for Spring Boot</description> 

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.5.9.RELEASE</version> 
    <relativePath/> <!-- lookup parent from repository --> 
</parent> 

<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
    <java.version>1.9</java.version> 
</properties> 

<dependencies> 

    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-jpa</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.derby</groupId> 
     <artifactId>derby</artifactId> 
     <scope>runtime</scope> 
    </dependency> 

</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-maven-plugin</artifactId> 
     </plugin> 
    </plugins> 
</build> 

enter image description here

콘솔 :

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

2017-12-29 20:29:50.365 INFO 2941 --- [   main] c.e.demo.SpringboottopicsApplication  : Starting SpringboottopicsApplication on Abhays-MacBook-Air.local with PID 2941 (/Users/abhaysingh/Documents/workspace-sts-3.9.2.RELEASE/springboottopics/target/classes started by abhaysingh in /Users/abhaysingh/Documents/workspace-sts-3.9.2.RELEASE/springboottopics) 
2017-12-29 20:29:50.373 INFO 2941 --- [   main] c.e.demo.SpringboottopicsApplication  : No active profile set, falling back to default profiles: default 
2017-12-29 20:29:50.481 INFO 2941 --- [   main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]17503f6b: startup date [Fri Dec 29 20:29:50 IST 2017]; root of context hierarchy 
WARNING: An illegal reflective access operation has occurred 
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/Users/abhaysingh/.m2/repository/org/springframework/spring-core/4.3.13.RELEASE/spring-core-4.3.13.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) 
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations 
WARNING: All illegal access operations will be denied in a future release 
2017-12-29 20:29:53.356 INFO 2941 --- [   main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 
2017-12-29 20:29:53.402 INFO 2941 --- [   main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 
2017-12-29 20:29:53.405 INFO 2941 --- [   main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.23 
2017-12-29 20:29:53.690 INFO 2941 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]  : Initializing Spring embedded WebApplicationContext 
2017-12-29 20:29:53.691 INFO 2941 --- [ost-startStop-1] o.s.web.context.ContextLoader   : Root WebApplicationContext: initialization completed in 3231 ms 
2017-12-29 20:29:54.249 INFO 2941 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 
2017-12-29 20:29:54.275 INFO 2941 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 
2017-12-29 20:29:54.276 INFO 2941 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 
2017-12-29 20:29:54.277 INFO 2941 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 
2017-12-29 20:29:54.278 INFO 2941 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 
2017-12-29 20:29:57.297 INFO 2941 --- [   main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default' 
2017-12-29 20:29:57.352 INFO 2941 --- [   main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [ 
    name: default 
    ...] 
2017-12-29 20:29:57.627 INFO 2941 --- [   main] org.hibernate.Version     : HHH000412: Hibernate Core {5.0.12.Final} 
2017-12-29 20:29:57.634 INFO 2941 --- [   main] org.hibernate.cfg.Environment   : HHH000206: hibernate.properties not found 
2017-12-29 20:29:57.640 INFO 2941 --- [   main] org.hibernate.cfg.Environment   : HHH000021: Bytecode provider name : javassist 
2017-12-29 20:29:57.686 WARN 2941 --- [   main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 
2017-12-29 20:29:57.696 INFO 2941 --- [   main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 
2017-12-29 20:29:57.760 INFO 2941 --- [   main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 
2017-12-29 20:29:57.807 ERROR 2941 --- [   main] o.s.boot.SpringApplication    : Application startup failed 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE] 
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE] 
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE] 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE] 
    at com.example.demo.SpringboottopicsApplication.main(SpringboottopicsApplication.java:12) [classes/:na] 
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 
    at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final] 
    at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final] 
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:179) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final] 
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:149) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final] 
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:54) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:382) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336) ~[spring-orm-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.13.RELEASE.jar:4.3.13.RELEASE] 
    ... 16 common frames omitted 
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException 
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) ~[na:na] 
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185) ~[na:na] 
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ~[na:na] 
    ... 27 common frames omitted 
+0

가 누락되었습니다. –

+0

관련 항목 : [link] (https://stackoverflow.com/questions/43574426/how-to-resolve-java-lang-noclassdeffounderror-javax-xml-bind-jaxbexception-in-j) – Jialzate

답변

0

spring.datasource, hibernate dialects를 application.properties에 등록 했습니까? 그냥 의심

에 대한

spring.datasource.url=jdbc:mysql://localhost:3306/database 
spring.datasource.username=root 
spring.datasource.password=root 

spring.datasource.driverClassName=com.mysql.jdbc.Driver 
spring.jpa.show-sql=true 
spring.jpa.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect 
spring.jpa.hibernate.ddl-auto = none 

처럼 당신은 당신이 추가 종속성으로 JAXB를 추가 할 필요가 자바 (9)와 최대 절전 모드 코어 의존성

<dependency> 
    <groupId>org.hibernate</groupId> 
    <artifactId>hibernate-core</artifactId> 
    <version>5.0.11.Final</version> 
</dependency> 
+0

여전히 동일합니다. 그것을 시도, – user3395246