Accessing Data with JPA: Application run failed
Authenticating a User with LDAP: Connection refused
Creating a Batch Service: Parsing error at line
samplecj / myspringboot Goto Github PK
View Code? Open in Web Editor NEW学习笔记
学习笔记
本人在该项目实践中遇到的错误,其实已在官方github项目上的issue中有过提出和解答。但在这些反馈并没有及时更新到Guides文档或github项目的readMe上。
正确配置已于github项目的complete文件夹中。
在localhost:8080/
中输入user
和password
后,得到如下反馈:
org.springframework.ldap.CommunicationException: localhost:8389; nested exception is javax.naming.CommunicationException: localhost:8389 [Root exception is java.net.ConnectException: Connection refused]
这可能是缺少某种配置文件映射。
解决方法
我们新增配置文件application.properties
,于以下文件路径
gs-authenticating-ldap\src\main\resources`application.properties
application.properties
内容如下:
spring.ldap.embedded.ldif=classpath:test-server.ldif
spring.ldap.embedded.base-dn=dc=springframework,dc=org
spring.ldap.embedded.port=8389
注意文本规范,即不应在每句行末留下空格。
这里捉一个虫,不算作代码实现的错误。
本篇Guide在Build with your IDE\Business Data
下给了表格文件sample-data.csv
的内容,并提供一键复制的功能,但该复制会在Excel中成为,
Jill,Doe
Joe,Doe
Justin,Doe
Jane,Doe
John,Doe
而实际上,在clone本项目中你会发现,实际sample-data.csv
应为2列5行的电子表格,
Jill | Doe
Joe | Doe
Justin | Doe
Jane | Doe
John | Doe
以上。
由于个人开发环境与官方文档的差异,因此即使clone项目并注入代码,也有遇上阻碍。
在错误报告log.ERROR(...)
2018-10-19 13:43:18.927 ERROR 18992 --- [ main] o.s.boot.SpringApplication : Application run failed
其下首行
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
划重点
Invocation of init method failed
nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
前者描述问题结果,后者指出可能的错误源JAXBException
,即与jaxb-api
有关。
这是jdk版本更替所诱发的问题。在jdk8.X至jdk9.X的更新中,jdk9.X为实现模块化,将原本于jdk8.X上仍默认捆绑的jaxb-api
剔除其默认路径。
简而言之,我们的配置路径上缺少了jaxb-api
的jar包。
若是build with Gradle
,只需要在build.gradle文件中添加相应的依赖语句即可。
解决办法
所求依赖语句,应于Maven Repository中搜索jaxb-api
可得。点入并选择最新或合适的稳定版本。
在页面下方,会有Maven
,Gradle
等的选项卡,选择我们的Gradle
,得到依赖语句,
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.X.X
我们需要手动添加依赖关系:
具体为
dependencies {
...
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.X.X
...
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.