Caused by java.lang.ClassNotFoundException javax.xml.bind.ValidationException异常

简介: Caused by java.lang.ClassNotFoundException javax.xml.bind.ValidationException异常

Caused by: java.lang.ClassNotFoundException: javax.xml.bind.ValidationException异常

问题描述:

"C:\Program Files\Java\jdk-10\bin\java" -javaagent:D:\IDE\IDEA\ideaIU-2018.1.win\lib\idea_rt.jar=55613:D:\IDE\IDEA\ideaIU-2018.1.win\bin -Dfile.encoding=UTF-8 -classpath D:\IDE\IDEA\Workspace\parent\eureka-server\target\classes;D:\IDE\Maven\Repository\org\springframework\cloud\spring-cloud-starter-eureka-server\1.2.1.RELEASE\spring-cloud-starter-eureka-server-1.2.1.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\cloud\spring-cloud-starter\1.1.4.RELEASE\spring-cloud-starter-1.1.4.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\boot\spring-boot-starter\1.4.1.RELEASE\spring-boot-starter-1.4.1.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\boot\spring-boot\1.4.1.RELEASE\spring-boot-1.4.1.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\spring-context\4.3.3.RELEASE\spring-context-4.3.3.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\boot\spring-boot-autoconfigure\1.4.1.RELEASE\spring-boot-autoconfigure-1.4.1.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\boot\spring-boot-starter-logging\1.4.1.RELEASE\spring-boot-starter-logging-1.4.1.RELEASE.jar;D:\IDE\Maven\Repository\ch\qos\logback\logback-classic\1.1.7\logback-classic-1.1.7.jar;D:\IDE\Maven\Repository\ch\qos\logback\logback-core\1.1.7\logback-core-1.1.7.jar;D:\IDE\Maven\Repository\org\slf4j\jcl-over-slf4j\1.7.21\jcl-over-slf4j-1.7.21.jar;D:\IDE\Maven\Repository\org\slf4j\jul-to-slf4j\1.7.21\jul-to-slf4j-1.7.21.jar;D:\IDE\Maven\Repository\org\slf4j\log4j-over-slf4j\1.7.21\log4j-over-slf4j-1.7.21.jar;D:\IDE\Maven\Repository\org\springframework\spring-core\4.3.3.RELEASE\spring-core-4.3.3.RELEASE.jar;D:\IDE\Maven\Repository\org\yaml\snakeyaml\1.17\snakeyaml-1.17.jar;D:\IDE\Maven\Repository\org\springframework\cloud\spring-cloud-context\1.1.4.RELEASE\spring-cloud-context-1.1.4.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\security\spring-security-crypto\4.1.3.RELEASE\spring-security-crypto-4.1.3.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\cloud\spring-cloud-commons\1.1.4.RELEASE\spring-cloud-commons-1.1.4.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\security\spring-security-rsa\1.0.3.RELEASE\spring-security-rsa-1.0.3.RELEASE.jar;D:\IDE\Maven\Repository\org\bouncycastle\bcpkix-jdk15on\1.55\bcpkix-jdk15on-1.55.jar;D:\IDE\Maven\Repository\org\bouncycastle\bcprov-jdk15on\1.55\bcprov-jdk15on-1.55.jar;D:\IDE\Maven\Repository\org\springframework\cloud\spring-cloud-netflix-eureka-server\1.2.1.RELEASE\spring-cloud-netflix-eureka-server-1.2.1.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\boot\spring-boot-starter-web\1.4.1.RELEASE\spring-boot-starter-web-1.4.1.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\boot\spring-boot-starter-tomcat\1.4.1.RELEASE\spring-boot-starter-tomcat-1.4.1.RELEASE.jar;D:\IDE\Maven\Repository\org\apache\tomcat\embed\tomcat-embed-core\8.5.5\tomcat-embed-core-8.5.5.jar;D:\IDE\Maven\Repository\org\apache\tomcat\embed\tomcat-embed-el\8.5.5\tomcat-embed-el-8.5.5.jar;D:\IDE\Maven\Repository\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.5\tomcat-embed-websocket-8.5.5.jar;D:\IDE\Maven\Repository\org\hibernate\hibernate-validator\5.2.4.Final\hibernate-validator-5.2.4.Final.jar;D:\IDE\Maven\Repository\javax\validation\validation-api\1.1.0.Final\validation-api-1.1.0.Final.jar;D:\IDE\Maven\Repository\org\jboss\logging\jboss-logging\3.3.0.Final\jboss-logging-3.3.0.Final.jar;D:\IDE\Maven\Repository\com\fasterxml\classmate\1.3.1\classmate-1.3.1.jar;D:\IDE\Maven\Repository\org\springframework\spring-web\4.3.3.RELEASE\spring-web-4.3.3.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\spring-aop\4.3.3.RELEASE\spring-aop-4.3.3.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\spring-beans\4.3.3.RELEASE\spring-beans-4.3.3.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\spring-webmvc\4.3.3.RELEASE\spring-webmvc-4.3.3.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\spring-expression\4.3.3.RELEASE\spring-expression-4.3.3.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\boot\spring-boot-starter-actuator\1.4.1.RELEASE\spring-boot-starter-actuator-1.4.1.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\boot\spring-boot-actuator\1.4.1.RELEASE\spring-boot-actuator-1.4.1.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\boot\spring-boot-starter-freemarker\1.4.1.RELEASE\spring-boot-starter-freemarker-1.4.1.RELEASE.jar;D:\IDE\Maven\Repository\org\freemarker\freemarker\2.3.25-incubating\freemarker-2.3.25-incubating.jar;D:\IDE\Maven\Repository\org\springframework\spring-context-support\4.3.3.RELEASE\spring-context-support-4.3.3.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\cloud\spring-cloud-netflix-core\1.2.1.RELEASE\spring-cloud-netflix-core-1.2.1.RELEASE.jar;D:\IDE\Maven\Repository\org\springframework\cloud\spring-cloud-netflix-eureka-client\1.2.1.RELEASE\spring-cloud-netflix-eureka-client-1.2.1.RELEASE.jar;D:\IDE\Maven\Repository\com\netflix\eureka\eureka-client\1.4.11\eureka-client-1.4.11.jar;D:\IDE\Maven\Repository\org\codehaus\jettison\jettison\1.3.7\jettison-1.3.7.jar;D:\IDE\Maven\Repository\stax\stax-api\1.0.1\stax-api-1.0.1.jar;D:\IDE\Maven\Repository\com\netflix\netflix-commons\netflix-eventbus\0.3.0\netflix-eventbus-0.3.0.jar;D:\IDE\Maven\Repository\com\netflix\netflix-commons\netflix-infix\0.3.0\netflix-infix-0.3.0.jar;D:\IDE\Maven\Repository\commons-jxpath\commons-jxpath\1.3\commons-jxpath-1.3.jar;D:\IDE\Maven\Repository\joda-time\joda-time\2.9.4\joda-time-2.9.4.jar;D:\IDE\Maven\Repository\org\antlr\antlr-runtime\3.4\antlr-runtime-3.4.jar;D:\IDE\Maven\Repository\org\antlr\stringtemplate\3.2.1\stringtemplate-3.2.1.jar;D:\IDE\Maven\Repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;D:\IDE\Maven\Repository\com\google\code\gson\gson\2.7\gson-2.7.jar;D:\IDE\Maven\Repository\org\apache\commons\commons-math\2.2\commons-math-2.2.jar;D:\IDE\Maven\Repository\javax\ws\rs\jsr311-api\1.1.1\jsr311-api-1.1.1.jar;D:\IDE\Maven\Repository\com\netflix\servo\servo-core\0.10.1\servo-core-0.10.1.jar;D:\IDE\Maven\Repository\com\netflix\servo\servo-internal\0.10.1\servo-internal-0.10.1.jar;D:\IDE\Maven\Repository\com\sun\jersey\jersey-core\1.19.1\jersey-core-1.19.1.jar;D:\IDE\Maven\Repository\com\sun\jersey\jersey-client\1.19.1\jersey-client-1.19.1.jar;D:\IDE\Maven\Repository\com\sun\jersey\contribs\jersey-apache-client4\1.19.1\jersey-apache-client4-1.19.1.jar;D:\IDE\Maven\Repository\org\apache\httpcomponents\httpclient\4.5.2\httpclient-4.5.2.jar;D:\IDE\Maven\Repository\org\apache\httpcomponents\httpcore\4.4.5\httpcore-4.4.5.jar;D:\IDE\Maven\Repository\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;D:\IDE\Maven\Repository\com\google\inject\guice\4.0\guice-4.0.jar;D:\IDE\Maven\Repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;D:\IDE\Maven\Repository\com\netflix\governator\governator-api\1.12.10\governator-api-1.12.10.jar;D:\IDE\Maven\Repository\com\sun\jersey\jersey-servlet\1.19.1\jersey-servlet-1.19.1.jar;D:\IDE\Maven\Repository\com\sun\jersey\jersey-server\1.19.1\jersey-server-1.19.1.jar;D:\IDE\Maven\Repository\com\netflix\eureka\eureka-core\1.4.11\eureka-core-1.4.11.jar;D:\IDE\Maven\Repository\com\netflix\governator\governator\1.12.10\governator-1.12.10.jar;D:\IDE\Maven\Repository\com\netflix\governator\governator-core\1.12.10\governator-core-1.12.10.jar;D:\IDE\Maven\Repository\com\google\inject\extensions\guice-multibindings\4.0\guice-multibindings-4.0.jar;D:\IDE\Maven\Repository\com\google\inject\extensions\guice-grapher\4.0\guice-grapher-4.0.jar;D:\IDE\Maven\Repository\com\google\inject\extensions\guice-assistedinject\4.0\guice-assistedinject-4.0.jar;D:\IDE\Maven\Repository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;D:\IDE\Maven\Repository\org\codehaus\woodstox\woodstox-core-asl\4.4.1\woodstox-core-asl-4.4.1.jar;D:\IDE\Maven\Repository\javax\xml\stream\stax-api\1.0-2\stax-api-1.0-2.jar;D:\IDE\Maven\Repository\com\netflix\archaius\archaius-core\0.7.4\archaius-core-0.7.4.jar;D:\IDE\Maven\Repository\com\google\code\findbugs\jsr305\3.0.1\jsr305-3.0.1.jar;D:\IDE\Maven\Repository\javax\inject\javax.inject\1\javax.inject-1.jar;D:\IDE\Maven\Repository\com\fasterxml\jackson\dataformat\jackson-dataformat-xml\2.8.3\jackson-dataformat-xml-2.8.3.jar;D:\IDE\Maven\Repository\com\fasterxml\jackson\module\jackson-module-jaxb-annotations\2.8.3\jackson-module-jaxb-annotations-2.8.3.jar;D:\IDE\Maven\Repository\org\codehaus\woodstox\stax2-api\3.1.4\stax2-api-3.1.4.jar;D:\IDE\Maven\Repository\com\fasterxml\woodstox\woodstox-core\5.0.2\woodstox-core-5.0.2.jar;D:\IDE\Maven\Repository\com\thoughtworks\xstream\xstream\1.4.9\xstream-1.4.9.jar;D:\IDE\Maven\Repository\xmlpull\xmlpull\1.1.3.1\xmlpull-1.1.3.1.jar;D:\IDE\Maven\Repository\xpp3\xpp3_min\1.1.4c\xpp3_min-1.1.4c.jar;D:\IDE\Maven\Repository\org\springframework\cloud\spring-cloud-starter-archaius\1.2.1.RELEASE\spring-cloud-starter-archaius-1.2.1.RELEASE.jar;D:\IDE\Maven\Repository\commons-configuration\commons-configuration\1.8\commons-configuration-1.8.jar;D:\IDE\Maven\Repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;D:\IDE\Maven\Repository\com\fasterxml\jackson\core\jackson-annotations\2.8.3\jackson-annotations-2.8.3.jar;D:\IDE\Maven\Repository\com\fasterxml\jackson\core\jackson-core\2.8.3\jackson-core-2.8.3.jar;D:\IDE\Maven\Repository\com\fasterxml\jackson\core\jackson-databind\2.8.3\jackson-databind-2.8.3.jar;D:\IDE\Maven\Repository\com\google\guava\guava\18.0\guava-18.0.jar;D:\IDE\Maven\Repository\org\springframework\cloud\spring-cloud-starter-ribbon\1.2.1.RELEASE\spring-cloud-starter-ribbon-1.2.1.RELEASE.jar;D:\IDE\Maven\Repository\com\netflix\ribbon\ribbon\2.2.0\ribbon-2.2.0.jar;D:\IDE\Maven\Repository\com\netflix\ribbon\ribbon-transport\2.2.0\ribbon-transport-2.2.0.jar;D:\IDE\Maven\Repository\io\reactivex\rxnetty-contexts\0.4.9\rxnetty-contexts-0.4.9.jar;D:\IDE\Maven\Repository\io\reactivex\rxnetty-servo\0.4.9\rxnetty-servo-0.4.9.jar;D:\IDE\Maven\Repository\com\netflix\hystrix\hystrix-core\1.5.6\hystrix-core-1.5.6.jar;D:\IDE\Maven\Repository\org\hdrhistogram\HdrHistogram\2.1.9\HdrHistogram-2.1.9.jar;D:\IDE\Maven\Repository\io\reactivex\rxnetty\0.4.9\rxnetty-0.4.9.jar;D:\IDE\Maven\Repository\io\netty\netty-codec-http\4.0.27.Final\netty-codec-http-4.0.27.Final.jar;D:\IDE\Maven\Repository\io\netty\netty-codec\4.0.27.Final\netty-codec-4.0.27.Final.jar;D:\IDE\Maven\Repository\io\netty\netty-handler\4.0.27.Final\netty-handler-4.0.27.Final.jar;D:\IDE\Maven\Repository\io\netty\netty-transport-native-epoll\4.0.27.Final\netty-transport-native-epoll-4.0.27.Final.jar;D:\IDE\Maven\Repository\io\netty\netty-common\4.0.27.Final\netty-common-4.0.27.Final.jar;D:\IDE\Maven\Repository\io\netty\netty-buffer\4.0.27.Final\netty-buffer-4.0.27.Final.jar;D:\IDE\Maven\Repository\io\netty\netty-transport\4.0.27.Final\netty-transport-4.0.27.Final.jar;D:\IDE\Maven\Repository\com\netflix\ribbon\ribbon-core\2.2.0\ribbon-core-2.2.0.jar;D:\IDE\Maven\Repository\com\netflix\ribbon\ribbon-httpclient\2.2.0\ribbon-httpclient-2.2.0.jar;D:\IDE\Maven\Repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;D:\IDE\Maven\Repository\com\netflix\netflix-commons\netflix-commons-util\0.1.1\netflix-commons-util-0.1.1.jar;D:\IDE\Maven\Repository\com\netflix\ribbon\ribbon-loadbalancer\2.2.0\ribbon-loadbalancer-2.2.0.jar;D:\IDE\Maven\Repository\com\netflix\netflix-commons\netflix-statistics\0.1.1\netflix-statistics-0.1.1.jar;D:\IDE\Maven\Repository\io\reactivex\rxjava\1.1.10\rxjava-1.1.10.jar;D:\IDE\Maven\Repository\com\netflix\ribbon\ribbon-eureka\2.2.0\ribbon-eureka-2.2.0.jar;D:\IDE\Maven\Repository\org\slf4j\slf4j-api\1.7.21\slf4j-api-1.7.21.jar top.sibma1949.App
2018-04-11 16:38:43.876  INFO 9224 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@3b00856b: startup date [Wed Apr 11 16:38:43 CST 2018]; root of context hierarchy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/D:/IDE/Maven/Repository/org/springframework/spring-core/4.3.3.RELEASE/spring-core-4.3.3.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
2018-04-11 16:38:44.256  INFO 9224 --- [           main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2018-04-11 16:38:44.285  INFO 9224 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$4db73157] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-04-11 16:38:44.422  WARN 9224 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'encryptionBootstrapConfiguration': Unsatisfied dependency expressed through field 'key'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'encrypt-org.springframework.cloud.bootstrap.encrypt.KeyProperties': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/ValidationException
2018-04-11 16:38:44.427  INFO 9224 --- [           main] utoConfigurationReportLoggingInitializer : 
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-04-11 16:38:44.448 ERROR 9224 --- [           main] o.s.boot.SpringApplication               : Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'encryptionBootstrapConfiguration': Unsatisfied dependency expressed through field 'key'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'encrypt-org.springframework.cloud.bootstrap.encrypt.KeyProperties': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/ValidationException
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1219) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:751) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:138) [spring-cloud-context-1.1.4.RELEASE.jar:1.1.4.RELEASE]
  at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:84) [spring-cloud-context-1.1.4.RELEASE.jar:1.1.4.RELEASE]
  at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:62) [spring-cloud-context-1.1.4.RELEASE.jar:1.1.4.RELEASE]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166) [spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138) [spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:121) [spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:68) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:337) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at top.sibma1949.App.main(App.java:11) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'encrypt-org.springframework.cloud.bootstrap.encrypt.KeyProperties': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/ValidationException
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1128) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1056) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:566) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  ... 29 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/ValidationException
  at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
  at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1009) ~[na:na]
  at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) ~[na:na]
  at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:801) ~[na:na]
  at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:699) ~[na:na]
  at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:622) ~[na:na]
  at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580) ~[na:na]
  at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190) ~[na:na]
  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499) ~[na:na]
  at org.hibernate.validator.internal.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:129) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
  at org.hibernate.validator.internal.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:96) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
  at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:31) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
  at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:276) ~[validation-api-1.1.0.Final.jar:na]
  at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:248) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor$LocalValidatorFactory.run(ConfigurationPropertiesBindingPostProcessor.java:452) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.getValidator(ConfigurationPropertiesBindingPostProcessor.java:386) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.determineValidator(ConfigurationPropertiesBindingPostProcessor.java:369) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:331) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:302) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1575) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  ... 38 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.ValidationException
  at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) ~[na:na]
  at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190) ~[na:na]
  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499) ~[na:na]
  ... 60 common frames omitted
2018-04-11 16:38:44.452  WARN 9224 --- [           main] o.s.boot.SpringApplication               : Error handling failed (no error message)
2018-04-11 16:38:44.453 ERROR 9224 --- [           main] o.s.boot.SpringApplication               : Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'encryptionBootstrapConfiguration': Unsatisfied dependency expressed through field 'key'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'encrypt-org.springframework.cloud.bootstrap.encrypt.KeyProperties': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/ValidationException
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1219) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:751) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:138) ~[spring-cloud-context-1.1.4.RELEASE.jar:1.1.4.RELEASE]
  at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:84) ~[spring-cloud-context-1.1.4.RELEASE.jar:1.1.4.RELEASE]
  at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:62) ~[spring-cloud-context-1.1.4.RELEASE.jar:1.1.4.RELEASE]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:121) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:68) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:337) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at top.sibma1949.App.main(App.java:11) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'encrypt-org.springframework.cloud.bootstrap.encrypt.KeyProperties': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/ValidationException
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1128) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1056) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:566) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  ... 29 common frames omitted
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/ValidationException
  at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
  at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1009) ~[na:na]
  at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) ~[na:na]
  at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:801) ~[na:na]
  at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:699) ~[na:na]
  at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:622) ~[na:na]
  at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:580) ~[na:na]
  at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190) ~[na:na]
  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499) ~[na:na]
  at org.hibernate.validator.internal.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:129) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
  at org.hibernate.validator.internal.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:96) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
  at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:31) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
  at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:276) ~[validation-api-1.1.0.Final.jar:na]
  at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:248) ~[spring-context-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor$LocalValidatorFactory.run(ConfigurationPropertiesBindingPostProcessor.java:452) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.getValidator(ConfigurationPropertiesBindingPostProcessor.java:386) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.determineValidator(ConfigurationPropertiesBindingPostProcessor.java:369) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:331) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:302) ~[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1575) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.3.3.RELEASE.jar:4.3.3.RELEASE]
  ... 38 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.ValidationException
  at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) ~[na:na]
  at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190) ~[na:na]
  at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499) ~[na:na]
  ... 60 common frames omitted
Process finished with exit code 1


问题分析:


JAXB API是java EE 的API,因此在java SE 9.0 中不再包含这个 Jar 包。

java 9 中引入了模块的概念,默认情况下,Java SE中将不再包含java EE 的Jar包

而在 java 6/7 / 8 时关于这个API 都是捆绑在一起的


解决方案:

引入下面依赖即可


jaxb-api maven地址:http://mvnrepository.com/artifact/javax.xml.bind/jaxb-api


jaxb-impl maven地址:http://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl


jaxb-core maven地址:http://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core


activation maven地址:http://mvnrepository.com/artifact/javax.activation/activation

<dependency>
     <groupId>javax.xml.bind</groupId>
     <artifactId>jaxb-api</artifactId>
     <version>2.3.0</version>
 </dependency>
 <dependency>
     <groupId>com.sun.xml.bind</groupId>
     <artifactId>jaxb-impl</artifactId>
     <version>2.3.0</version>
 </dependency>
 <dependency>
     <groupId>com.sun.xml.bind</groupId>
     <artifactId>jaxb-core</artifactId>
     <version>2.3.0</version>
 </dependency>
 <dependency>
     <groupId>javax.activation</groupId>
     <artifactId>activation</artifactId>
     <version>1.1.1</version>
 </dependency>


目录
相关文章
|
1月前
|
Java
在 Java 中捕获和处理自定义异常的代码示例
本文提供了一个 Java 代码示例,展示了如何捕获和处理自定义异常。通过创建自定义异常类并使用 try-catch 语句,可以更灵活地处理程序中的错误情况。
59 1
|
1月前
|
Java API 调度
如何避免 Java 中的 TimeoutException 异常
在Java中,`TimeoutException`通常发生在执行操作超过预设时间时。要避免此异常,可以优化代码逻辑,减少不必要的等待;合理设置超时时间,确保其足够完成正常操作;使用异步处理或线程池管理任务,提高程序响应性。
62 12
|
1月前
|
Java
在 Java 中,如何自定义`NumberFormatException`异常
在Java中,自定义`NumberFormatException`异常可以通过继承`IllegalArgumentException`类并重写其构造方法来实现。自定义异常类可以添加额外的错误信息或行为,以便更精确地处理特定的数字格式转换错误。
34 1
|
1月前
|
IDE 前端开发 Java
怎样避免 Java 中的 NoSuchFieldError 异常
在Java中避免NoSuchFieldError异常的关键在于确保类路径下没有不同版本的类文件冲突,避免反射时使用不存在的字段,以及确保所有依赖库版本兼容。编译和运行时使用的类版本应保持一致。
66 7
|
1月前
|
Java 编译器
如何避免在 Java 中出现 NoSuchElementException 异常
在Java中,`NoSuchElementException`通常发生在使用迭代器、枚举或流等遍历集合时,尝试访问不存在的元素。为了避免该异常,可以在访问前检查是否有下一个元素(如使用`hasNext()`方法),或者使用`Optional`类处理可能为空的情况。正确管理集合边界和条件判断是关键。
70 6
|
1月前
|
Java
Java异常捕捉处理和错误处理
Java异常捕捉处理和错误处理
64 1
|
1月前
|
Java 编译器 开发者
Java异常处理的最佳实践,涵盖理解异常类体系、选择合适的异常类型、提供详细异常信息、合理使用try-catch和finally语句、使用try-with-resources、记录异常信息等方面
本文探讨了Java异常处理的最佳实践,涵盖理解异常类体系、选择合适的异常类型、提供详细异常信息、合理使用try-catch和finally语句、使用try-with-resources、记录异常信息等方面,帮助开发者提高代码质量和程序的健壮性。
60 2
|
1月前
|
Java
如何在 Java 中处理“Broken Pipe”异常
在Java中处理“Broken Pipe”异常,通常发生在网络通信中,如Socket编程时。该异常表示写入操作的另一端已关闭连接。解决方法包括:检查网络连接、设置超时、使用try-catch捕获异常并进行重试或关闭资源。
104 5
|
1月前
|
存储 安全 Java
如何避免 Java 中的“ArrayStoreException”异常
在Java中,ArrayStoreException异常通常发生在尝试将不兼容的对象存储到泛型数组中时。为了避免这种异常,确保在操作数组时遵循以下几点:1. 使用泛型确保类型安全;2. 避免生类型(raw types)的使用;3. 在添加元素前进行类型检查。通过这些方法,可以有效防止 ArrayStoreException 的发生。
41 3
|
2月前
|
人工智能 Oracle Java
解决 Java 打印日志吞异常堆栈的问题
前几天有同学找我查一个空指针问题,Java 打印日志时,异常堆栈信息被吞了,导致定位不到出问题的地方。
43 2
下一篇
DataWorks