Spring data with multiple modules not workingHow to solve “Plugin execution not covered by lifecycle configuration” for Spring Data Maven BuildsWhat is difference between CrudRepository and JpaRepository interfaces in Spring Data JPA?spring-data mongodb custom implementation PropertyReferenceExceptionSpring Data: inject 2 repositories with same name but in 2 different packagesHow to disable spring-data-mongodb autoconfiguration in spring-bootSpring Boot not autowiring @RepositorySpring data reuse Repository classIs there a way to register a repository base class with a spring boot auto configuration?Spring Data JPA - Multiple EnableJpaRepositoriesHow to spread Entities over different modules in Spring-data-jpa and eclipselink?
Which centaur is more 'official'?
Why are there so many religions and gods?
Different budgets within roommate group
Why are 120 V general receptacle circuits limited to 20 A?
Why did this meteor appear cyan?
Acceleration in Circular motion
Loss of majority in Westminster
What exactly is a fey/fiend/celestial spirit?
What could a reptilian race tell by candling their eggs?
Is there a way for presidents to legally extend their terms beyond the maximum of four years?
Most elegant way to write a one shot IF
The Confused Alien
Who gets an Apparition licence?
Is it bad to describe a character long after their introduction?
Details of video memory access arbitration in Space Invaders
Why does a brace command group need spaces after the opening brace in POSIX Shell Grammar?
3D nonogram, beginner's edition
How was film developed in the late 1920s?
Why won't the ground take my seed?
I'm reinstalling my Linux desktop, how do I keep SSH logins working?
What's the safest way to inform a new user of their password on my web site?
One folder two different locations on ubuntu 18.04
Using aluminium busbar/cables in an aircraft instead of copper
Can you sign using a digital signature itself?
Spring data with multiple modules not working
How to solve “Plugin execution not covered by lifecycle configuration” for Spring Data Maven BuildsWhat is difference between CrudRepository and JpaRepository interfaces in Spring Data JPA?spring-data mongodb custom implementation PropertyReferenceExceptionSpring Data: inject 2 repositories with same name but in 2 different packagesHow to disable spring-data-mongodb autoconfiguration in spring-bootSpring Boot not autowiring @RepositorySpring data reuse Repository classIs there a way to register a repository base class with a spring boot auto configuration?Spring Data JPA - Multiple EnableJpaRepositoriesHow to spread Entities over different modules in Spring-data-jpa and eclipselink?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to set up a project with two data sources, one is MongoDB and the other is Postgres. I have repositories for each data source in different packages and I annotated my main class as follows:
@Import(MongoDBConfiguration.class, PostgresDBConfiguration.class)
@SpringBootApplication(exclude =
MongoRepositoriesAutoConfiguration.class,
JpaRepositoriesAutoConfiguration.class
)
public class TemporaryRunner implements CommandLineRunner
...
MongoDBConfiguration:
@Configuration
@EnableMongoRepositories(basePackages =
"com.example.datastore.mongo",
"com.atlassian.connect.spring")
public class MongoDBConfiguration
...
PostgresDBConfiguration:
@Configuration
@EnableJpaRepositories(basePackages =
"com.example.datastore.postgres"
)
public class PostgresDBConfiguration
...
And even though I specified the base packages as described in documentation, I still get those messages in the console:
13:10:44.238 [main] [] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode!
13:10:44.266 [main] [] INFO o.s.d.r.c.RepositoryConfigurationExtensionSupport - Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.atlassian.connect.spring.AtlassianHostRepository.
I managed to solve this issue for all my repositories by using MongoRepository and JpaRepository but AtlassianHostRepository comes from an external lib and it is a regular CrudRepository (which totally makes sense because the consumer of the lib can decide what type of DB he would like to use). Anyway it looks that basePackages I specified are completely ignored and not used in any way, even though I specified com.atlassian.connect.spring package only in @EnableMongoRepositories Spring Data somehow can't figure out which data module should be used.
Am I doing something wrong? Is there any other way I could tell spring data to use mongo for AtlassianHostRepository without changing the AtlassianHostRepository.class itself?
spring-boot spring-data-jpa spring-data spring-data-mongodb
add a comment |
I'm trying to set up a project with two data sources, one is MongoDB and the other is Postgres. I have repositories for each data source in different packages and I annotated my main class as follows:
@Import(MongoDBConfiguration.class, PostgresDBConfiguration.class)
@SpringBootApplication(exclude =
MongoRepositoriesAutoConfiguration.class,
JpaRepositoriesAutoConfiguration.class
)
public class TemporaryRunner implements CommandLineRunner
...
MongoDBConfiguration:
@Configuration
@EnableMongoRepositories(basePackages =
"com.example.datastore.mongo",
"com.atlassian.connect.spring")
public class MongoDBConfiguration
...
PostgresDBConfiguration:
@Configuration
@EnableJpaRepositories(basePackages =
"com.example.datastore.postgres"
)
public class PostgresDBConfiguration
...
And even though I specified the base packages as described in documentation, I still get those messages in the console:
13:10:44.238 [main] [] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode!
13:10:44.266 [main] [] INFO o.s.d.r.c.RepositoryConfigurationExtensionSupport - Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.atlassian.connect.spring.AtlassianHostRepository.
I managed to solve this issue for all my repositories by using MongoRepository and JpaRepository but AtlassianHostRepository comes from an external lib and it is a regular CrudRepository (which totally makes sense because the consumer of the lib can decide what type of DB he would like to use). Anyway it looks that basePackages I specified are completely ignored and not used in any way, even though I specified com.atlassian.connect.spring package only in @EnableMongoRepositories Spring Data somehow can't figure out which data module should be used.
Am I doing something wrong? Is there any other way I could tell spring data to use mongo for AtlassianHostRepository without changing the AtlassianHostRepository.class itself?
spring-boot spring-data-jpa spring-data spring-data-mongodb
add a comment |
I'm trying to set up a project with two data sources, one is MongoDB and the other is Postgres. I have repositories for each data source in different packages and I annotated my main class as follows:
@Import(MongoDBConfiguration.class, PostgresDBConfiguration.class)
@SpringBootApplication(exclude =
MongoRepositoriesAutoConfiguration.class,
JpaRepositoriesAutoConfiguration.class
)
public class TemporaryRunner implements CommandLineRunner
...
MongoDBConfiguration:
@Configuration
@EnableMongoRepositories(basePackages =
"com.example.datastore.mongo",
"com.atlassian.connect.spring")
public class MongoDBConfiguration
...
PostgresDBConfiguration:
@Configuration
@EnableJpaRepositories(basePackages =
"com.example.datastore.postgres"
)
public class PostgresDBConfiguration
...
And even though I specified the base packages as described in documentation, I still get those messages in the console:
13:10:44.238 [main] [] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode!
13:10:44.266 [main] [] INFO o.s.d.r.c.RepositoryConfigurationExtensionSupport - Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.atlassian.connect.spring.AtlassianHostRepository.
I managed to solve this issue for all my repositories by using MongoRepository and JpaRepository but AtlassianHostRepository comes from an external lib and it is a regular CrudRepository (which totally makes sense because the consumer of the lib can decide what type of DB he would like to use). Anyway it looks that basePackages I specified are completely ignored and not used in any way, even though I specified com.atlassian.connect.spring package only in @EnableMongoRepositories Spring Data somehow can't figure out which data module should be used.
Am I doing something wrong? Is there any other way I could tell spring data to use mongo for AtlassianHostRepository without changing the AtlassianHostRepository.class itself?
spring-boot spring-data-jpa spring-data spring-data-mongodb
I'm trying to set up a project with two data sources, one is MongoDB and the other is Postgres. I have repositories for each data source in different packages and I annotated my main class as follows:
@Import(MongoDBConfiguration.class, PostgresDBConfiguration.class)
@SpringBootApplication(exclude =
MongoRepositoriesAutoConfiguration.class,
JpaRepositoriesAutoConfiguration.class
)
public class TemporaryRunner implements CommandLineRunner
...
MongoDBConfiguration:
@Configuration
@EnableMongoRepositories(basePackages =
"com.example.datastore.mongo",
"com.atlassian.connect.spring")
public class MongoDBConfiguration
...
PostgresDBConfiguration:
@Configuration
@EnableJpaRepositories(basePackages =
"com.example.datastore.postgres"
)
public class PostgresDBConfiguration
...
And even though I specified the base packages as described in documentation, I still get those messages in the console:
13:10:44.238 [main] [] INFO o.s.d.r.c.RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode!
13:10:44.266 [main] [] INFO o.s.d.r.c.RepositoryConfigurationExtensionSupport - Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.atlassian.connect.spring.AtlassianHostRepository.
I managed to solve this issue for all my repositories by using MongoRepository and JpaRepository but AtlassianHostRepository comes from an external lib and it is a regular CrudRepository (which totally makes sense because the consumer of the lib can decide what type of DB he would like to use). Anyway it looks that basePackages I specified are completely ignored and not used in any way, even though I specified com.atlassian.connect.spring package only in @EnableMongoRepositories Spring Data somehow can't figure out which data module should be used.
Am I doing something wrong? Is there any other way I could tell spring data to use mongo for AtlassianHostRepository without changing the AtlassianHostRepository.class itself?
spring-boot spring-data-jpa spring-data spring-data-mongodb
spring-boot spring-data-jpa spring-data spring-data-mongodb
asked Mar 25 at 12:27
enterbiosenterbios
1,3527 silver badges8 bronze badges
1,3527 silver badges8 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The only working solution I found was to let spring data ignore AtlassianHostRepository (because it couldn't figure out which data source to use) then create a separate configuration for it, and simply create it by hand:
@Configuration
@Import(MongoDBConfiguration.class)
public class AtlassianHostRepositoryConfiguration
private final MongoTemplate mongoTemplate;
@Autowired
public AtlassianHostRepositoryConfiguration(final MongoTemplate mongoTemplate)
this.mongoTemplate = mongoTemplate;
@Bean
public AtlassianHostRepository atlassianHostRepository()
RepositoryFactorySupport factory = new MongoRepositoryFactory(mongoTemplate);
return factory.getRepository(AtlassianHostRepository.class);
This solution works fine for a small or limited number of repositories used from a library, it would be rather cumbersome to create all the repositories by hand when there are more of them, but after reading the source code of spring-data I see no way to make it work with basePackages as stated in documentation (I may be wrong though).
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55337783%2fspring-data-with-multiple-modules-not-working%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The only working solution I found was to let spring data ignore AtlassianHostRepository (because it couldn't figure out which data source to use) then create a separate configuration for it, and simply create it by hand:
@Configuration
@Import(MongoDBConfiguration.class)
public class AtlassianHostRepositoryConfiguration
private final MongoTemplate mongoTemplate;
@Autowired
public AtlassianHostRepositoryConfiguration(final MongoTemplate mongoTemplate)
this.mongoTemplate = mongoTemplate;
@Bean
public AtlassianHostRepository atlassianHostRepository()
RepositoryFactorySupport factory = new MongoRepositoryFactory(mongoTemplate);
return factory.getRepository(AtlassianHostRepository.class);
This solution works fine for a small or limited number of repositories used from a library, it would be rather cumbersome to create all the repositories by hand when there are more of them, but after reading the source code of spring-data I see no way to make it work with basePackages as stated in documentation (I may be wrong though).
add a comment |
The only working solution I found was to let spring data ignore AtlassianHostRepository (because it couldn't figure out which data source to use) then create a separate configuration for it, and simply create it by hand:
@Configuration
@Import(MongoDBConfiguration.class)
public class AtlassianHostRepositoryConfiguration
private final MongoTemplate mongoTemplate;
@Autowired
public AtlassianHostRepositoryConfiguration(final MongoTemplate mongoTemplate)
this.mongoTemplate = mongoTemplate;
@Bean
public AtlassianHostRepository atlassianHostRepository()
RepositoryFactorySupport factory = new MongoRepositoryFactory(mongoTemplate);
return factory.getRepository(AtlassianHostRepository.class);
This solution works fine for a small or limited number of repositories used from a library, it would be rather cumbersome to create all the repositories by hand when there are more of them, but after reading the source code of spring-data I see no way to make it work with basePackages as stated in documentation (I may be wrong though).
add a comment |
The only working solution I found was to let spring data ignore AtlassianHostRepository (because it couldn't figure out which data source to use) then create a separate configuration for it, and simply create it by hand:
@Configuration
@Import(MongoDBConfiguration.class)
public class AtlassianHostRepositoryConfiguration
private final MongoTemplate mongoTemplate;
@Autowired
public AtlassianHostRepositoryConfiguration(final MongoTemplate mongoTemplate)
this.mongoTemplate = mongoTemplate;
@Bean
public AtlassianHostRepository atlassianHostRepository()
RepositoryFactorySupport factory = new MongoRepositoryFactory(mongoTemplate);
return factory.getRepository(AtlassianHostRepository.class);
This solution works fine for a small or limited number of repositories used from a library, it would be rather cumbersome to create all the repositories by hand when there are more of them, but after reading the source code of spring-data I see no way to make it work with basePackages as stated in documentation (I may be wrong though).
The only working solution I found was to let spring data ignore AtlassianHostRepository (because it couldn't figure out which data source to use) then create a separate configuration for it, and simply create it by hand:
@Configuration
@Import(MongoDBConfiguration.class)
public class AtlassianHostRepositoryConfiguration
private final MongoTemplate mongoTemplate;
@Autowired
public AtlassianHostRepositoryConfiguration(final MongoTemplate mongoTemplate)
this.mongoTemplate = mongoTemplate;
@Bean
public AtlassianHostRepository atlassianHostRepository()
RepositoryFactorySupport factory = new MongoRepositoryFactory(mongoTemplate);
return factory.getRepository(AtlassianHostRepository.class);
This solution works fine for a small or limited number of repositories used from a library, it would be rather cumbersome to create all the repositories by hand when there are more of them, but after reading the source code of spring-data I see no way to make it work with basePackages as stated in documentation (I may be wrong though).
answered Mar 25 at 18:42
enterbiosenterbios
1,3527 silver badges8 bronze badges
1,3527 silver badges8 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55337783%2fspring-data-with-multiple-modules-not-working%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown