Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
Ejecute el script MongoDB al iniciar Spring Boot

Necesito inicializar un Mongo DB con algún archivo de script como Spring do con JPA y el archivo import.sql ... pero ¿cómo?

¿Alguien me puede ayudar?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Podrías usar algo similar hecho por mongeez . Esto es básicamente un iniciador para spring-boot que ejecuta scripts antes de que se inicialicen los beans spring-data-mongodb.

over 4 years ago · Santiago Trujillo Report

0

Puede acompañar y aprovechar el ciclo de vida de inicialización de spring-boot, donde después de conectar los beans, ejecuta todos los beans CommandLineRunner .

 @SpringBootApplication public class YourApplication { final Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private MongoRepository repo; @Bean CommandLineRunner preLoadMongo() throws Exception { return args -> { //repo.doSOmethingInMongoDB } public static void main(String[] args) { SpringApplication.run(YourApplication.class, args); }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!