use of org.springframework.core.env.Environment in project rdbcache by rdbcache.
the class Application method main.
public static void main(String[] args) {
if (args != null && args.length > 0) {
for (int i = 0; i < args.length; i++) {
if (args[i].equals("-v") || args[i].equals("--version")) {
System.out.println("\n" + AppCtx.getVersionInfo().getFullInfo() + "\n");
return;
}
}
}
SpringApplication app = new SpringApplication(Application.class);
app.setBanner(new Banner() {
@Override
public void printBanner(Environment environment, Class<?> aClass, PrintStream printStream) {
printStream.println("\n" + AppCtx.getVersionInfo().getFullInfo() + "\n");
}
});
ConfigurableApplicationContext context = app.run(args);
}
use of org.springframework.core.env.Environment in project nikita-noark5-core by HiOA-ABI.
the class N5CoreApp method main.
/**
* Main method, used to run the application.
*
* @param args the command line arguments
* @throws UnknownHostException if the local host name could not be resolved into an address
*/
public static void main(final String... args) throws UnknownHostException {
//SpringApplication app = new SpringApplication(N5CoreApp.class);
//SimpleCommandLinePropertySource source = new SimpleCommandLinePropertySource(args);
ConfigurableApplicationContext context = SpringApplication.run(CONFIGS, args);
context.getBean(AfterApplicationStartup.class).afterApplicationStarts();
Environment env = context.getEnvironment();
String[] activeProfiles = env.getActiveProfiles();
String profilesAsString = Arrays.toString(activeProfiles);
logger.info("\n----------------------------------------------------------\n\t" + "Application '{}' is running! Access URLs:\n\t" + "Local: \t\t\thttp://localhost:{}\n\t" + "External: \t\thttp://{}:{}\n\t" + "contextPath: \thttp://{}:{}{} \n\t" + "Application is running with following profile(s): {} \n\t" + "\n----------------------------------------------------------", env.getProperty("spring.application.name"), env.getProperty("server.port"), InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port"), InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port"), env.getProperty("server.contextPath"), profilesAsString);
String configServerStatus = env.getProperty("configserver.status");
logger.info("\n----------------------------------------------------------\n\t" + "Config Server: \t{}\n----------------------------------------------------------", configServerStatus == null ? "Not found or not setup for this application" : configServerStatus);
if (profilesAsString != null && profilesAsString.contains("de")) {
logger.info("\n----------------------------------------------------------\n\t" + "Dev/demo mode: In-memory database ({}) in use. See http://localhost:8082 . Use following JDBC-string: jdbc:h2:mem:n5DemoDb/jdbc:h2:mem:n5DevDb" + "\n----------------------------------------------------------", env.getProperty("spring.jpa.database"));
}
}
use of org.springframework.core.env.Environment in project spring-data-commons by spring-projects.
the class CustomRepositoryImplementationDetector method findCandidateBeanDefinitions.
Set<BeanDefinition> findCandidateBeanDefinitions(String className, Iterable<String> basePackages, Iterable<TypeFilter> excludeFilters) {
// Build pattern to lookup implementation class
Pattern pattern = Pattern.compile(".*\\." + className);
// Build classpath scanner and lookup bean definition
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false, environment);
provider.setResourceLoader(resourceLoader);
provider.setResourcePattern(String.format(CUSTOM_IMPLEMENTATION_RESOURCE_PATTERN, className));
provider.setMetadataReaderFactory(metadataReaderFactory);
provider.addIncludeFilter(new RegexPatternTypeFilter(pattern));
excludeFilters.forEach(it -> provider.addExcludeFilter(it));
return //
Streamable.of(basePackages).stream().flatMap(//
it -> provider.findCandidateComponents(it).stream()).collect(Collectors.toSet());
}
use of org.springframework.core.env.Environment in project jhipster-sample-app-elasticsearch by jhipster.
the class JhipsterElasticsearchSampleApplicationApp method main.
/**
* Main method, used to run the application.
*
* @param args the command line arguments
*/
public static void main(String[] args) {
SpringApplication app = new SpringApplication(JhipsterElasticsearchSampleApplicationApp.class);
DefaultProfileUtil.addDefaultProfile(app);
Environment env = app.run(args).getEnvironment();
String protocol = "http";
if (env.getProperty("server.ssl.key-store") != null) {
protocol = "https";
}
String hostAddress = "localhost";
try {
hostAddress = InetAddress.getLocalHost().getHostAddress();
} catch (Exception e) {
log.warn("The host name could not be determined, using `localhost` as fallback");
}
log.info("\n----------------------------------------------------------\n\t" + "Application '{}' is running! Access URLs:\n\t" + "Local: \t\t{}://localhost:{}\n\t" + "External: \t{}://{}:{}\n\t" + "Profile(s): \t{}\n----------------------------------------------------------", env.getProperty("spring.application.name"), protocol, env.getProperty("server.port"), protocol, hostAddress, env.getProperty("server.port"), env.getActiveProfiles());
}
use of org.springframework.core.env.Environment in project jhipster-sample-app-dto by jhipster.
the class JhipsterDtoSampleApplicationApp method main.
/**
* Main method, used to run the application.
*
* @param args the command line arguments
*/
public static void main(String[] args) {
SpringApplication app = new SpringApplication(JhipsterDtoSampleApplicationApp.class);
DefaultProfileUtil.addDefaultProfile(app);
Environment env = app.run(args).getEnvironment();
String protocol = "http";
if (env.getProperty("server.ssl.key-store") != null) {
protocol = "https";
}
String hostAddress = "localhost";
try {
hostAddress = InetAddress.getLocalHost().getHostAddress();
} catch (Exception e) {
log.warn("The host name could not be determined, using `localhost` as fallback");
}
log.info("\n----------------------------------------------------------\n\t" + "Application '{}' is running! Access URLs:\n\t" + "Local: \t\t{}://localhost:{}\n\t" + "External: \t{}://{}:{}\n\t" + "Profile(s): \t{}\n----------------------------------------------------------", env.getProperty("spring.application.name"), protocol, env.getProperty("server.port"), protocol, hostAddress, env.getProperty("server.port"), env.getActiveProfiles());
}
Aggregations