JWT 错误Unresolvable dependency resolving
调用代码
$token = JWTAuth::attempt($credentials)
会报错。
BindingResolutionException in Container.php line 850:
Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Cache\CacheManager
in Container.php line 850
at Container->resolveNonClass(object(ReflectionParameter)) in Container.php line 817
at Container->getDependencies(array(object(ReflectionParameter)), array()) in Container.php line 788
at Container->build('Illuminate\Cache\CacheManager', array()) in Container.php line 644
at Container->make('Illuminate\Cache\CacheManager', array()) in Application.php line 211
at Application->make('Illuminate\Cache\CacheManager') in Container.php line 864
at Container->resolveClass(object(ReflectionParameter)) in Container.php line 819
at Container->getDependencies(array(object(ReflectionParameter)), array()) in Container.php line 788
at Container->build('Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter', array()) in Container.php line 644
at Container->make('Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter', array()) in Application.php line 211
at Application->make('Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter') in JWTAuthServiceProvider.php line 273
at JWTAuthServiceProvider->getConfigInstance('Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter') in JWTAuthServiceProvider.php line 158
at JWTAuthServiceProvider->Tymon\JWTAuth\Providers\{closure}(object(Application)) in Container.php line 290
at Container->Illuminate\Container\{closure}(object(Application), array()) in Container.php line 746
at Container->build(object(Closure), array()) in Container.php line 644
at Container->make('tymon.jwt.provider.storage', array()) in Application.php line 211
at Application->make('tymon.jwt.provider.storage') in Container.php line 1203
at Container->offsetGet('tymon.jwt.provider.storage') in JWTAuthServiceProvider.php line 213
at JWTAuthServiceProvider->Tymon\JWTAuth\Providers\{closure}(object(Application)) in Container.php line 290
at Container->Illuminate\Container\{closure}(object(Application), array()) in Container.php line 746
at Container->build(object(Closure), array()) in Container.php line 644
at Container->make('tymon.jwt.blacklist', array()) in Application.php line 211
at Application->make('tymon.jwt.blacklist') in Container.php line 1203
at Container->offsetGet('tymon.jwt.blacklist') in JWTAuthServiceProvider.php line 181
at JWTAuthServiceProvider->Tymon\JWTAuth\Providers\{closure}(object(Application)) in Container.php line 290
at Container->Illuminate\Container\{closure}(object(Application), array()) in Container.php line 746
at Container->build(object(Closure), array()) in Container.php line 644
at Container->make('tymon.jwt.manager', array()) in Application.php line 211
at Application->make('tymon.jwt.manager') in Container.php line 1203
at Container->offsetGet('tymon.jwt.manager') in JWTAuthServiceProvider.php line 197
at JWTAuthServiceProvider->Tymon\JWTAuth\Providers\{closure}(object(Application)) in Container.php line 290
at Container->Illuminate\Container\{closure}(object(Application), array()) in Container.php line 746
at Container->build(object(Closure), array()) in Container.php line 644
at Container->make('tymon.jwt.auth', array()) in Application.php line 211
at Application->make('tymon.jwt.auth') in Container.php line 1203
at Container->offsetGet('tymon.jwt.auth') in Facade.php line 175
at Facade::resolveFacadeInstance('tymon.jwt.auth') in Facade.php line 144
at Facade::getFacadeRoot() in Facade.php line 231
at Facade::__callStatic('attempt', array(array('international_code' => '86', 'phone' => '18576627189', 'password' => '123456'))) in TokenController.php line 30
at TokenController->create(object(Request))
at call_user_func_array(array(object(TokenController), 'create'), array(object(Request))) in Container.php line 508
at Container->call(array(object(TokenController), 'create'), array()) in RoutesRequests.php line 610
at Application->callControllerCallable(array(object(TokenController), 'create'), array()) in RoutesRequests.php line 576
at Application->callLumenController(object(TokenController), 'create', array(true, array('uses' => 'App\Http\Controllers\TokenController@create'), array())) in RoutesRequests.php line 550
at Application->callControllerAction(array(true, array('uses' => 'App\Http\Controllers\TokenController@create'), array())) in RoutesRequests.php line 512
at Application->callActionOnArrayBasedRoute(array(true, array('uses' => 'App\Http\Controllers\TokenController@create'), array())) in RoutesRequests.php line 497
at Application->handleFoundRoute(array(true, array('uses' => 'App\Http\Controllers\TokenController@create'), array())) in RoutesRequests.php line 394
at Application->Laravel\Lumen\Concerns\{closure}() in RoutesRequests.php line 650
at Application->sendThroughPipeline(array(), object(Closure)) in RoutesRequests.php line 400
at Application->dispatch(null) in RoutesRequests.php line 341
at Application->run() in index.php line 28
at require('/Users/panxiaohe/Sites/api/public/index.php') in server.php line 106
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的Lumen版本是5.5,报错的原因是cache和auth没有开启,在Lumen默认是关闭的。
打开bootstrap/app.php,在你的jwt配置下开启cache和auth,添加如下代码:
这样就可以解决了,happy coding!!