SparkJava不能与一些Google Youtube API一起使用
我们决定使用SparkJava,Kotlin和Mustache作为商业网络产品。 我们的产品需要与Google(YouTube)API集成。
该项目的所有终端正常工作。 (后台,CRUD操作等),我们开始实施YouTube的集成,我不得不将谷歌图书馆添加到我的项目开始。 (不要添加任何额外的代码,只需添加库google-oauth-client-jetty。)
你可以在下面find我的Gradle库:
dependencies { // Below library is a part of the requirements or YouTube Integration compile group: 'com.google.oauth-client', name: 'google-oauth-client-jetty', version: '1.11.0-beta' // And these are the others compile fileTree(include: ['*.jar'], dir: 'lib') compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile group: 'com.sparkjava', name: 'spark-core', version: '2.7.0' compile 'com.google.code.gson:gson:2.8.1' compile group: 'commons-codec', name: 'commons-codec', version: '1.9' compile 'com.github.jkcclemens:khttp:0.1.0' // -SNAPSHOT compile 'com.beust:klaxon:0.30' compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.58' compile group: 'org.hibernate', name: 'hibernate-gradle-plugin', version: '5.2.10.Final' compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.10.Final' compile group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.2.10.Final' compile group: 'org.hibernate', name: 'hibernate-validator', version: '6.0.0.CR3' compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.6' compile group: 'org.hibernate', name: 'hibernate-c3p0', version: '4.1.0.Final' compile 'io.sentry:sentry-log4j:1.4.0' compile group: 'javax.mail', name: 'mail', version: '1.4.1' compile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.0' compile group: 'commons-validator', name: 'commons-validator', version: '1.4.0' compile "org.testng:testng:6.9.10" compile "org.apache.httpcomponents:httpclient:4.5.2" compile "org.apache.httpcomponents:httpcore:4.4.4" compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0' compile group: 'com.sparkjava', name: 'spark-template-mustache', version: '2.5.5' compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25' testCompile group: 'junit', name: 'junit', version: '4.11' }
当我特别添加库“google-oauth-client-jetty”版本:“1.11.0-beta”到项目中时,我无法通过http(GET,POST,PUT都无法到达端点)。 我启用了SparkJava的日志,我正在面对下面的日志。
例如,我在打电话
HTTP://本地主机:3000 /管理员
结果是:
[qtp1864334028-15] WARN org.eclipse.jetty.server.HttpChannel - /admin java.lang.NoSuchMethodError: javax.servlet.http.HttpServletResponse.getHeaders(Ljava/lang/String;)Ljava/util/Collection; at spark.utils.GzipUtils.checkAndWrap(GzipUtils.java:67) at spark.http.matching.Body.serializeTo(Body.java:69) at spark.http.matching.MatcherFilter.doFilter(MatcherFilter.java:189) at spark.embeddedserver.jetty.JettyHandler.doHandle(JettyHandler.java:50) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1568) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.Server.handle(Server.java:564) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110) at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124) at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128) at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591) at java.lang.Thread.run(Thread.java:745)
因为看起来,在google-oauth-client-jetty库中使用方法“LocalServerReceiver()”是相当强制的。
我们需要任何帮助继续前进。
我发现这个问题:
google-oauth-client-jetty(LocalServerReceiver)使用的是旧版本的servlet-api的org.mortbay.jetty。 (2.5。**)
我排除和改变LocalServerReceiver类..把我的包。 并将jetty更改为org.eclipse.jetty。