Newer
Older
newfiber-data-adapter / src / main / java / org / springnewfiber / dataadapter / config / PrimaryMongoConfig.java
package org.springnewfiber.dataadapter.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.mongodb.core.MongoTemplate;

/**
 * 监测数据mongo库
 * @author xiebinbin
 * @since 2023/5/6 15:10
 */
@Configuration
@ConfigurationProperties(prefix = "spring.data.mongodb.primary")
public class PrimaryMongoConfig extends AbstractMongoConfig{

    @Primary
    @Override
    @Bean(name = "mongoTemplate")
    public MongoTemplate getMongoTemplate() throws Exception {
        return new MongoTemplate(mongoDbFactory());
    }

}