Skip to content

Commit

Permalink
feat: move to runapplication
Browse files Browse the repository at this point in the history
  • Loading branch information
sendilkumarn committed Mar 7, 2018
1 parent df5a0ab commit 6444722
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import <%=packageName%>.config.DefaultProfileUtil
import io.github.jhipster.config.JHipsterConstants

import org.slf4j.LoggerFactory
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
<%_ if (databaseType === 'sql') { _%>
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties
Expand Down Expand Up @@ -97,9 +96,11 @@ class <%= mainClass %>(private val env: Environment) {
@JvmStatic
fun main(args: Array<String>) {
val log = LoggerFactory.getLogger(<%= mainClass %>::class.java)
val app = SpringApplication(<%= mainClass %>::class.java)
DefaultProfileUtil.addDefaultProfile(app)
val env = app.run(*args).environment

val env = runApplication<<%= mainClass %>> {
setDefaultProperties(DefaultProfileUtil.addDefaultProfile())
}.environment

var protocol = "http"
if (env.getProperty("server.ssl.key-store") != null) {
protocol = "https"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ package <%=packageName%>.config

import io.github.jhipster.config.JHipsterConstants

import org.springframework.boot.SpringApplication
import org.springframework.core.env.Environment

import java.util.*
import kotlin.collections.HashMap

/**
* Utility class to load a Spring profile to be used as default
Expand All @@ -43,15 +42,15 @@ class DefaultProfileUtil {
*
* @param app the Spring application
*/
fun addDefaultProfile(app: SpringApplication) {
fun addDefaultProfile(): Map<String, Any>? {
val defProperties = HashMap<String, String>()
/*
* 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 as kotlin.collections.Map<String, Any>?)
defProperties[SPRING_PROFILE_DEFAULT] = JHipsterConstants.SPRING_PROFILE_DEVELOPMENT
return defProperties
}

/**
Expand Down

0 comments on commit 6444722

Please sign in to comment.