0

I'm using Spring 5.1+ with MongoDB. One of my classes is annotated with @Document so it gets picked up by MongoDB, however this is causing the program to fail tests as it times out waiting for the Mongo Service which isn't running.

Is there a way to disable the @Document annotation specifically based on the current profile? I've attempted doing things like:

@Profile("production")
@Document
public class MyRepoObject { ...

And using custom @Conditional annotations in the place of @Profile however that hasn't fixed the problem.

I'm certain it's the @Document annotation causing the error as the tests pass when I comment out the annotation.

SchoolJava101
  • 609
  • 1
  • 5
  • 8

1 Answers1

0

The solution as JEY pointed out was to disable the Mongo Auto Configurations for the test environments.

I excluded MongoAutoConfiguration.class, MongoDataAutoConfiguration.class, MongoRepositoriesAutoConfiguration.class and all tests passed.

SchoolJava101
  • 609
  • 1
  • 5
  • 8