Java Code Examples for org.springframework.boot.SpringApplication#setDefaultProperties()
The following examples show how to use
org.springframework.boot.SpringApplication#setDefaultProperties() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogbackIntegrationTest.java From sofa-common-tools with Apache License 2.0 | 6 votes |
/** * test sofa.middleware.log.console.logback.pattern config */ @Test public void testLogbackLogConsolePattern() { Map<String, Object> properties = new HashMap<String, Object>(); properties.put(Constants.SOFA_MIDDLEWARE_ALL_LOG_CONSOLE_SWITCH, "true"); properties.put(Constants.SOFA_MIDDLEWARE_LOG_CONSOLE_LOGBACK_PATTERN, "logback-test-console-pattern" + Constants.SOFA_MIDDLEWARE_LOG_CONSOLE_LOGBACK_PATTERN_DEFAULT); SpringApplication springApplication = new SpringApplication(EmptyConfig.class); springApplication.setDefaultProperties(properties); springApplication.run(new String[] {}); logger.info("global space console"); Assert.assertTrue(outContent.toString().contains("logback-test-console-pattern")); LogEnvUtils.processGlobalSystemLogProperties().remove( Constants.SOFA_MIDDLEWARE_ALL_LOG_CONSOLE_SWITCH); LogEnvUtils.processGlobalSystemLogProperties().remove( Constants.SOFA_MIDDLEWARE_LOG_CONSOLE_LOGBACK_PATTERN); }
Example 2
Source File: AbstractMainConfigurationFileInvalidTest.java From logback-access-spring-boot-starter with Apache License 2.0 | 6 votes |
/** * Tests a Logback-access configuration exception in the case where the main configuration file is invalid. */ @Test public void logbackAccessConfigurationExceptionWhereMainConfigurationFileIsInvalid() { Map<String, Object> properties = new HashMap<>(); properties.put("server.port", findAvailableTcpPort()); SpringApplication application = new SpringApplication(contextConfiguration); application.setDefaultProperties(properties); Throwable throwable = catchThrowable(application::run); Optional<LogbackAccessConfigurationException> exc = findLogbackAccessConfigurationException(throwable); assertThat(exc).hasValueSatisfying(value -> assertThat(value) .hasMessageStartingWith("Could not configure Logback-access:") .hasMessageContaining("config=[classpath:logback-access.xml]") .hasCauseInstanceOf(JoranException.class) ); }
Example 3
Source File: LogbackIntegrationTest.java From sofa-common-tools with Apache License 2.0 | 6 votes |
/** * test sofa.middleware.log.console.level config */ @Test public void testGlobalConsoleLevelConfig() { Map<String, Object> properties = new HashMap<String, Object>(); properties.put(Constants.SOFA_MIDDLEWARE_ALL_LOG_CONSOLE_SWITCH, "true"); properties.put(Constants.SOFA_MIDDLEWARE_ALL_LOG_CONSOLE_LEVEL, "debug"); SpringApplication springApplication = new SpringApplication(EmptyConfig.class); springApplication.setDefaultProperties(properties); springApplication.run(new String[] {}); logger.info("global space console"); logger.debug("global space console debug"); Assert.assertTrue(outContent.toString().contains("global space console")); Assert.assertTrue(outContent.toString().contains("global space console debug")); LogEnvUtils.processGlobalSystemLogProperties().remove( Constants.SOFA_MIDDLEWARE_ALL_LOG_CONSOLE_SWITCH); LogEnvUtils.processGlobalSystemLogProperties().remove( Constants.SOFA_MIDDLEWARE_ALL_LOG_CONSOLE_LEVEL); }
Example 4
Source File: Application.java From clamav-rest with GNU Lesser General Public License v2.1 | 5 votes |
public static void main(String[] args) { SpringApplication app = new SpringApplication(Application.class); Map<String, Object> defaults = new HashMap<String, Object>(); defaults.put("clamd.host", "192.168.50.72"); defaults.put("clamd.port", 3310); defaults.put("clamd.timeout", 500); defaults.put("clamd.maxfilesize", "20000KB"); defaults.put("clamd.maxrequestsize", "20000KB"); app.setDefaultProperties(defaults); app.run(args); }
Example 5
Source File: DefaultProfileUtil.java From cubeai with Apache License 2.0 | 5 votes |
/** * Set a default to use when no profile is configured. * * @param app the Spring application */ public static void addDefaultProfile(SpringApplication app) { Map<String, Object> defProperties = new HashMap<>(); /* * The default profile to use when no other profiles are defined * This cannot be set in the <code>application.yml</code> file. * See https://github.com/spring-projects/spring-boot/issues/1219 */ defProperties.put(SPRING_PROFILE_DEFAULT, JHipsterConstants.SPRING_PROFILE_DEVELOPMENT); app.setDefaultProperties(defProperties); }
Example 6
Source File: DefaultProfileUtil.java From cubeai with Apache License 2.0 | 5 votes |
/** * Set a default to use when no profile is configured. * * @param app the Spring application */ public static void addDefaultProfile(SpringApplication app) { Map<String, Object> defProperties = new HashMap<>(); /* * The default profile to use when no other profiles are defined * This cannot be set in the <code>application.yml</code> file. * See https://github.com/spring-projects/spring-boot/issues/1219 */ defProperties.put(SPRING_PROFILE_DEFAULT, JHipsterConstants.SPRING_PROFILE_DEVELOPMENT); app.setDefaultProperties(defProperties); }
Example 7
Source File: DefaultProfileUtil.java From Full-Stack-Development-with-JHipster with MIT License | 5 votes |
/** * Set a default to use when no profile is configured. * * @param app the Spring application */ public static void addDefaultProfile(SpringApplication app) { Map<String, Object> defProperties = new HashMap<>(); /* * The default profile to use when no other profiles are defined * This cannot be set in the <code>application.yml</code> file. * See https://github.com/spring-projects/spring-boot/issues/1219 */ defProperties.put(SPRING_PROFILE_DEFAULT, JHipsterConstants.SPRING_PROFILE_DEVELOPMENT); app.setDefaultProperties(defProperties); }
Example 8
Source File: PortalApplication.java From JavaQuarkBBS with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws IOException { //更改properties配置文件名称,避免依赖冲突 Properties properties = new Properties(); InputStream in = PortalApplication.class.getClassLoader().getResourceAsStream("portal.properties"); properties.load(in); SpringApplication app = new SpringApplication(PortalApplication.class); app.setDefaultProperties(properties); app.run(args); }
Example 9
Source File: SpringBoot2IntrospectBizEndpointOnArkEnabledTest.java From sofa-ark with Apache License 2.0 | 5 votes |
@Test public void testDisableBizStateEndpoint() { Map<String, Object> properties = new HashMap<>(); properties.put("management.endpoint.bizState.enabled", "false"); SpringApplication springApplication = new SpringApplication(EmptyConfiguration.class); springApplication.setDefaultProperties(properties); ConfigurableApplicationContext applicationContext = springApplication.run(new String[] {}); Assert.assertFalse(applicationContext.containsBean("introspectBizEndpoint")); applicationContext.close(); }
Example 10
Source File: AddressMigratorApp2.java From spring-batch-lightmin with Apache License 2.0 | 5 votes |
public static void main(final String[] args) { final SpringApplication application = new SpringApplication(AddressMigratorApp2.class); final Properties properties = new Properties(); properties.putIfAbsent("server.port", 9010); application.setDefaultProperties(properties); application.run(args); }
Example 11
Source File: DefaultProfileUtil.java From jhipster-microservices-example with Apache License 2.0 | 5 votes |
/** * Set a default to use when no profile is configured. * * @param app the Spring application */ public static void addDefaultProfile(SpringApplication app) { Map<String, Object> defProperties = new HashMap<>(); /* * The default profile to use when no other profiles are defined * This cannot be set in the <code>application.yml</code> file. * See https://github.com/spring-projects/spring-boot/issues/1219 */ defProperties.put(SPRING_PROFILE_DEFAULT, JHipsterConstants.SPRING_PROFILE_DEVELOPMENT); app.setDefaultProperties(defProperties); }
Example 12
Source File: DefaultProfileUtil.java From TeamDojo with Apache License 2.0 | 5 votes |
/** * Set a default to use when no profile is configured. * * @param app the Spring application */ public static void addDefaultProfile(SpringApplication app) { Map<String, Object> defProperties = new HashMap<>(); /* * The default profile to use when no other profiles are defined * This cannot be set in the <code>application.yml</code> file. * See https://github.com/spring-projects/spring-boot/issues/1219 */ defProperties.put(SPRING_PROFILE_DEFAULT, JHipsterConstants.SPRING_PROFILE_DEVELOPMENT); app.setDefaultProperties(defProperties); }
Example 13
Source File: DefaultProfileUtil.java From ehcache3-samples with Apache License 2.0 | 5 votes |
/** * Set a default to use when no profile is configured. * * @param app the Spring application */ public static void addDefaultProfile(SpringApplication app) { Map<String, Object> defProperties = new HashMap<>(); /* * The default profile to use when no other profiles are defined * This cannot be set in the <code>application.yml</code> file. * See https://github.com/spring-projects/spring-boot/issues/1219 */ defProperties.put(SPRING_PROFILE_DEFAULT, JHipsterConstants.SPRING_PROFILE_DEVELOPMENT); app.setDefaultProperties(defProperties); }
Example 14
Source File: Application.java From android-uiconductor with Apache License 2.0 | 5 votes |
public static void main(String[] args) { // To initialized the logger for spring. // Have to init here, otherwise, in other class we won't able to get logger. UicdCoreDelegator.getInstance(); if (loadFromConfigFile()) { return; } SpringApplication application = new SpringApplication(Application.class); application.setDefaultProperties(DataSourceConfig.getDBProperties()); Application.context = application.run(args); Application.args = args; }
Example 15
Source File: DefaultProfileUtil.java From 21-points with Apache License 2.0 | 5 votes |
/** * Set a default to use when no profile is configured. * * @param app the Spring application */ public static void addDefaultProfile(SpringApplication app) { Map<String, Object> defProperties = new HashMap<>(); /* * The default profile to use when no other profiles are defined * This cannot be set in the <code>application.yml</code> file. * See https://github.com/spring-projects/spring-boot/issues/1219 */ defProperties.put(SPRING_PROFILE_DEFAULT, JHipsterConstants.SPRING_PROFILE_DEVELOPMENT); app.setDefaultProperties(defProperties); }
Example 16
Source File: ChatApplication.java From JavaQuarkBBS with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws IOException { Properties properties = new Properties(); InputStream in = ChatApplication.class.getClassLoader().getResourceAsStream("chat.properties"); properties.load(in); SpringApplication app = new SpringApplication(ChatApplication.class); app.setDefaultProperties(properties); app.run(args); }
Example 17
Source File: Application.java From spring-boot-quickstart-archtype with Apache License 2.0 | 5 votes |
public static void main(String[] args) { final SpringApplication springApplication = new SpringApplication(Application.class); // ir is being added here for LOCAL run ONLY , spring profiles should be be run time parameters when run spring boot jar springApplication.setDefaultProperties(Collections.singletonMap("spring.profiles.default","LOCAL")); springApplication.addListeners(new ApplicationPidFileWriter()); springApplication.run(args); }
Example 18
Source File: Benchmarks.java From sdn-rx with Apache License 2.0 | 5 votes |
@Setup public void setup() { Map<String, Object> neo4jConfig = prepareNeo4j(); SpringApplication springApplication = new SpringApplication(); springApplication.addPrimarySources(Collections.singletonList(Application.class)); springApplication.setLazyInitialization(true); springApplication.setDefaultProperties(neo4jConfig); this.applicationContext = springApplication.run(); this.movieRepository = applicationContext.getBean(MovieRepository.class); this.driver = applicationContext.getBean(Driver.class); }
Example 19
Source File: Benchmarks.java From sdn-rx with Apache License 2.0 | 5 votes |
@Setup public void setup() { Map<String, Object> neo4jConfig = prepareNeo4j(); SpringApplication springApplication = new SpringApplication(); springApplication.addPrimarySources(Collections.singletonList(Application.class)); springApplication.setLazyInitialization(true); springApplication.setDefaultProperties(neo4jConfig); this.applicationContext = springApplication.run(); this.movieRepository = applicationContext.getBean(MovieRepository.class); this.driver = applicationContext.getBean(Driver.class); }
Example 20
Source File: JsonRpcConnectorBaseTest.java From kurento-java with Apache License 2.0 | 4 votes |
@BeforeClass public static void startServer() throws Exception { if (server == null || !server.isActive()) { System.setProperty("ws.maxSessions", Integer.toString(MAX_WS_CONNECTIONS)); System.setProperty("java.security.egd", "file:/dev/./urandom"); Properties properties = new Properties(); properties.put("server.port", getPort()); SpringApplication application = new SpringApplication(BootTestApplication.class); application.setDefaultProperties(properties); log.debug("Properties: {}", properties); server = application.run(); } }