zoukankan      html  css  js  c++  java
  • [Java Spring] Spring Expression Language

    Besides using Profiles, we can also us Spring Expression Language.

    package com.frankmoley.lil.fid.config;
    
    import com.frankmoley.lil.fid.service.GreetingService;
    import com.frankmoley.lil.fid.service.OutputService;
    import com.frankmoley.lil.fid.service.TimeService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.context.annotation.Profile;
    import org.springframework.context.annotation.PropertySource;
    
    @Configuration
    @PropertySource("classpath:application.properties")
    public class ApplicationConfig {
    
        @Value("${app.greeting}")
        private String greeting;
        @Value("${app.name}")
        private String name;
        @Value("#{new Boolean(environment['spring.profiles.active']!='dev')}")
        private boolean is24;
    
        @Autowired
        private GreetingService greetingService;
        @Autowired
        private TimeService timeService;
    
        @Bean
        public TimeService timeService(){
            return new TimeService(is24);
        }
    
    
        @Bean
        public OutputService outputService(){
            return new OutputService(greetingService, timeService, name);
        }
    
        @Bean
        public GreetingService greetingService(){
            return new GreetingService(greeting);
        }
    }
  • 相关阅读:
    补番完了 来自深渊
    160CrackMe第十九Brad Soblesky.2
    MyBio小隐本记注册破解
    WDTP注册破解
    对话框和普通窗口工作方式的区别
    Win32汇编学习(11):对话框(2)
    Win32汇编学习(10):对话框(1)
    MongoDB的复制源oplog
    Windows搭建MongoDB复制集
    MangoDB的下载和安装
  • 原文地址:https://www.cnblogs.com/Answer1215/p/14088053.html
Copyright © 2011-2022 走看看