property work
This commit is contained in:
parent
dee468a154
commit
52995a5194
@ -2,11 +2,9 @@ package org.baeldung.spring.config;
|
|||||||
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.ImportResource;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ImportResource("classpath:configForProperties.xml")
|
|
||||||
@ComponentScan("org.baeldung.core")
|
@ComponentScan("org.baeldung.core")
|
||||||
public class CoreConfig extends WebMvcConfigurerAdapter {
|
public class CoreConfig extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.baeldung.spring.properties;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.PropertySource;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ComponentScan("org.baeldung.core")
|
||||||
|
@PropertySource("classpath:foo.properties")
|
||||||
|
public class PropertiesWithJavaConfig extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
|
public PropertiesWithJavaConfig() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package org.baeldung.spring.properties;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.ImportResource;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@ImportResource("classpath:configForProperties.xml")
|
||||||
|
@ComponentScan("org.baeldung.core")
|
||||||
|
public class PropertiesWithXmlConfig extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
|
public PropertiesWithXmlConfig() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package org.baeldung.core;
|
||||||
|
|
||||||
|
import org.baeldung.spring.properties.PropertiesWithJavaConfig;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration(classes = { PropertiesWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
|
public class PropertiesWithJavaIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public final void givenContextIsInitialized_thenNoException() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package org.baeldung.core;
|
package org.baeldung.core;
|
||||||
|
|
||||||
import org.baeldung.spring.config.CoreConfig;
|
import org.baeldung.spring.properties.PropertiesWithXmlConfig;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
@ -8,8 +8,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = { CoreConfig.class }, loader = AnnotationConfigContextLoader.class)
|
@ContextConfiguration(classes = { PropertiesWithXmlConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||||
public class PropertiesViaXmlIntegrationTest {
|
public class PropertiesWithXmlIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void givenContextIsInitialized_thenNoException() {
|
public final void givenContextIsInitialized_thenNoException() {
|
Loading…
x
Reference in New Issue
Block a user