java - find another META-INF/persistence.xml -
i have problem: project search persistence.xml in directory
code
@configuration @enabletransactionmanagement @enablejparepositories( basepackages = {"com.psc.repository", "com.psc.export.itconfig.repositories"}, repositoryfactorybeanclass = customrepositoryfactorybean.class) @enablejpaauditing public class jpatestconfig { @bean public hibernatejpavendoradapter jpavendoradapter() { hibernatejpavendoradapter vendoradapter = new hibernatejpavendoradapter(); return vendoradapter; } @bean public localcontainerentitymanagerfactorybean entitymanagerfactory() { localcontainerentitymanagerfactorybean factory = new localcontainerentitymanagerfactorybean(); factory.setpersistenceunitname("psc_test"); return factory; } @bean public entitymanager entitymanager(entitymanagerfactory emf) { return emf.createentitymanager(); } @bean public platformtransactionmanager transactionmanager() { return new jpatransactionmanager(); } @bean auditoraware auditoraware() { return (auditoraware<string>) () -> { final string username = optional.ofnullable(vaadinservice.getcurrentrequest()) .map(request -> optional.ofnullable(request.getuserprincipal()) .map(principal -> principal.getname()) .orelse(request.getremoteuser())) .orelse(appdata.getappdata().getcurrentuser()); return username; }; } }
path of class above test\java\configurations\jpatestconfig.java
there xml file in path test\resources\meta-inf\persistence.xml
when run test refer persistence.xml in absolutely different package of project. how fix it? in persistence.xml doesn't exist unit (psc_test)
test class
@runwith(springjunit4classrunner.class) //@springapplicationconfiguration(classes = application.class) @webappconfiguration @contextconfiguration(classes = {jpatestconfig.class, servicesconfig.class, restservice.com.websystique.springmvc.configuration.restconfig.class}) public class branchcontrollertest { @autowired private webapplicationcontext wac; private mockmvc mockmvc; @before public void setup() { this.mockmvc = mockmvcbuilders.webappcontextsetup(this.wac).build(); } @test public void getfoo() throws exception { /* code here */ } }
firstly, times ambiguity occurs... testing purpose create new workspace , keeping project want test.dont keep unnecessary project if works or otherwise problem path. or else.. can change persistence name , check whether still pointing persistence.xml or not.
Comments
Post a Comment