Make executable jar work better as an embeddable
I think it's a good idea to provide an executable jar (good getting started experience), but it wasn't working very well. The biggest problem was the missing main() method, but that was easy to fix. More interestingly I have changed the default config name to "configserver" so "configserver.yml" is loaded to set the default config for the standalone jar, and this file can easily be ignored in a customized server. Fixes gh-17
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring-cloud.version>${project.version}</spring-cloud.version>
|
||||
<start-class>org.springframework.cloud.config.server.Application</start-class>
|
||||
<start-class>org.springframework.cloud.config.server.ConfigServerApplication</start-class>
|
||||
<java.version>1.7</java.version>
|
||||
</properties>
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.springframework.cloud.config.server;
|
||||
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@@ -8,4 +9,9 @@ import org.springframework.context.annotation.Configuration;
|
||||
@EnableConfigServer
|
||||
public class ConfigServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new SpringApplicationBuilder(ConfigServerApplication.class).properties(
|
||||
"spring.config.name=configserver").run(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,13 +9,15 @@ import org.springframework.boot.test.IntegrationTest;
|
||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
||||
import org.springframework.boot.test.TestRestTemplate;
|
||||
import org.springframework.cloud.config.Environment;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringApplicationConfiguration(classes = ConfigServerApplication.class)
|
||||
@IntegrationTest("server.port:0")
|
||||
@IntegrationTest({"server.port:0", "spring.config.name:configserver"})
|
||||
@WebAppConfiguration
|
||||
@ActiveProfiles("test")
|
||||
public class ApplicationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
|
||||
@@ -32,28 +32,28 @@ public class SpringApplicationEnvironmentRepositoryTests {
|
||||
@Test
|
||||
public void vanilla() {
|
||||
Environment environment = repository.findOne("foo", "development", "master");
|
||||
assertEquals(3, environment.getPropertySources().size());
|
||||
assertEquals(2, environment.getPropertySources().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ignoresExistingProfile() {
|
||||
System.setProperty("spring.profiles.active", "cloud");
|
||||
Environment environment = repository.findOne("foo", "main", "master");
|
||||
assertEquals(2, environment.getPropertySources().size());
|
||||
assertEquals(1, environment.getPropertySources().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefixed() {
|
||||
repository.setSearchLocations("classpath:/test");
|
||||
Environment environment = repository.findOne("foo", "development", "master");
|
||||
assertEquals(4, environment.getPropertySources().size());
|
||||
assertEquals(3, environment.getPropertySources().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prefixedWithFile() {
|
||||
repository.setSearchLocations("file:./src/test/resources/test");
|
||||
Environment environment = repository.findOne("foo", "development", "master");
|
||||
assertEquals(4, environment.getPropertySources().size());
|
||||
assertEquals(3, environment.getPropertySources().size());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user