All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sinszm.common.SzmCommonAutoConfiguration Maven / Gradle / Ivy

package com.sinszm.common;


import com.google.gson.Gson;
import org.springframework.beans.BeansException;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;

/**
 * Szm框架启动配置
 *
 * @author chenjianbo
 */
@ComponentScans({
        @ComponentScan("com.sinszm.*")
})
public class SzmCommonAutoConfiguration implements ApplicationContextAware {

    @ConditionalOnMissingBean(
            name = "gson",
            value = Gson.class
    )
    @Bean
    public Gson gson() {
        return new Gson()
                .newBuilder().create();
    }

    @Override
    public void setApplicationContext(ApplicationContext context) throws BeansException {
        SpringContext.instance().init(context);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy