i have problem injecting jparepository data provider.
i put @enablejparepositories annotation in episodieapiapplication.class located in package:
package pl.hypeapp.episodie;
@configuration @enableautoconfiguration @componentscan(basepackages = "pl.hypeapp.episodie.configuration") @enableadminserver @enablejparepositories public class episodieapiapplication extends springbootservletinitializer { public static void main(string[] args) { springapplication.run(episodieapiapplication.class, args); } @override protected springapplicationbuilder configure(springapplicationbuilder builder) { return builder.sources(episodieapiapplication.class); } }
databasedataproviderconfiguration.class located in pacakage
package pl.hypeapp.episodie.configuration.dataprovider;
@configuration public class databasedataproviderconfiguration { @bean public tvshowdatabaseprovider tvshowdatabaseprovider(tvshowrepository tvshowrepository) { return new tvshowdatabaseprovider(tvshowrepository); } }
tvshowrepository.class located in package
package pl.hypeapp.episodie.dataproviders.database;
public interface tvshowrepository extends jparepository<tvshow, string> { }
my databaseprovider in module application/dataproviders/database databasedataprovider.class
public class tvshowdatabaseprovider implements doestvshowexist, gettvshowfromdatabase, inserttvshowtodatabase { private final tvshowrepository tvshowrepository; public tvshowdatabaseprovider(tvshowrepository tvshowrepository) { this.tvshowrepository = tvshowrepository; } }
tvshow.class located in package:
package pl.hypeapp.core.entity.tvmaze;
@jsonignoreproperties(ignoreunknown = true) @data @entity public class tvshow { @jsonproperty("id") public integer id; }
but got error:
error creating bean name 'tvshowdatabaseprovider' defined in class path resource [pl/hypeapp/episodie/configuration/dataprovider/databasedataproviderconfiguration.class]: unsatisfied dependency expressed through method 'tvshowdatabaseprovider' parameter 0; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'tvshowrepository': invocation of init method failed; nested exception java.lang.illegalargumentexception: not managed type: class pl.hypeapp.core.entity.tvmaze.tvshow
whole code @ github incomplete , may not work due missing classes
your not scanning entities. use "pl.hypeapp"
basepackages @enablejparepository
or use @entityscan
:
@configuration @enableautoconfiguration @componentscan(basepackages = "pl.hypeapp.episodie.configuration") @enableadminserver @enablejparepositories(basepackages = {"pl.hypeapp.episodie.dataproviders"}) @entityscan(basepackages = {"pl.hypeapp.core.entity"}) public class episodieapiapplication extends springbootservletinitializer { public static void main(string[] args) { springapplication.run(episodieapiapplication.class, args); } @override protected springapplicationbuilder configure(springapplicationbuilder builder) { return builder.sources(episodieapiapplication.class); } }
Comments
Post a Comment