From b6996c86036de985658b4e4675d516fa539382a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Miller=20=28=E9=94=BA=E4=BF=8A=29?= Date: Tue, 29 Dec 2020 13:20:34 +0800 Subject: [PATCH] perf($Starter): abstract project property [skip ci] --- .../WebFluxSecurityConfiguration.java | 2 +- .../universal/configuration/Constants.java | 42 ------- .../configuration/ProjectProperty.java | 3 + .../maf/authcenter/AuthCenterApplication.java | 16 +-- .../service/impl/PermissionServiceImpl.java | 8 +- .../configuration/JwtConfiguration.java | 7 +- .../configuration/ProjectProperty.java | 37 ------- .../configuration/Swagger2Configuration.java | 19 ++-- .../service/impl/CommonServiceImpl.java | 6 +- .../src/main/resources/application.yml | 20 ++-- .../exercisemis/ExerciseMisApplication.java | 16 +-- .../configuration/ProjectProperty.java | 39 ------- .../configuration/Swagger2Configuration.java | 19 ++-- .../service/impl/CommonServiceImpl.java | 6 +- .../src/main/resources/application.yml | 6 +- .../maf/musclemis/MuscleMisApplication.java | 16 +-- .../configuration/ProjectProperty.java | 37 ------- .../configuration/Swagger2Configuration.java | 19 ++-- .../service/impl/CommonServiceImpl.java | 6 +- muscle-mis/src/main/resources/application.yml | 6 +- .../ServiceRegistryApplication.java | 16 +-- .../configuration/ProjectProperty.java | 37 ------- .../configuration/Swagger2Configuration.java | 19 ++-- .../service/impl/CommonServiceImpl.java | 6 +- .../src/main/resources/application.yml | 7 +- .../SpringBootAdminApplication.java | 16 +-- .../configuration/ProjectProperty.java | 37 ------- .../configuration/Swagger2Configuration.java | 19 ++-- .../service/impl/CommonServiceImpl.java | 6 +- .../src/main/resources/application.yml | 7 +- .../configuration/MafAutoConfiguration.java | 6 + .../configuration/MafProjectProperty.java | 103 ++++++++++++++++++ 32 files changed, 245 insertions(+), 364 deletions(-) rename api-gateway/src/main/java/com/jmsoftware/maf/apigateway/security/{ => configuration}/WebFluxSecurityConfiguration.java (98%) delete mode 100644 api-gateway/src/main/java/com/jmsoftware/maf/apigateway/universal/configuration/Constants.java delete mode 100644 auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/ProjectProperty.java delete mode 100644 exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/universal/configuration/ProjectProperty.java delete mode 100644 muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/universal/configuration/ProjectProperty.java delete mode 100644 service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/universal/configuration/ProjectProperty.java delete mode 100644 spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/universal/configuration/ProjectProperty.java create mode 100644 spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/MafProjectProperty.java diff --git a/api-gateway/src/main/java/com/jmsoftware/maf/apigateway/security/WebFluxSecurityConfiguration.java b/api-gateway/src/main/java/com/jmsoftware/maf/apigateway/security/configuration/WebFluxSecurityConfiguration.java similarity index 98% rename from api-gateway/src/main/java/com/jmsoftware/maf/apigateway/security/WebFluxSecurityConfiguration.java rename to api-gateway/src/main/java/com/jmsoftware/maf/apigateway/security/configuration/WebFluxSecurityConfiguration.java index 1c566b8b..7ea9147d 100644 --- a/api-gateway/src/main/java/com/jmsoftware/maf/apigateway/security/WebFluxSecurityConfiguration.java +++ b/api-gateway/src/main/java/com/jmsoftware/maf/apigateway/security/configuration/WebFluxSecurityConfiguration.java @@ -1,4 +1,4 @@ -package com.jmsoftware.maf.apigateway.security; +package com.jmsoftware.maf.apigateway.security.configuration; import com.jmsoftware.maf.apigateway.security.impl.*; import com.jmsoftware.maf.reactivespringbootstarter.configuration.MafConfiguration; diff --git a/api-gateway/src/main/java/com/jmsoftware/maf/apigateway/universal/configuration/Constants.java b/api-gateway/src/main/java/com/jmsoftware/maf/apigateway/universal/configuration/Constants.java deleted file mode 100644 index 214a4a76..00000000 --- a/api-gateway/src/main/java/com/jmsoftware/maf/apigateway/universal/configuration/Constants.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.jmsoftware.maf.apigateway.universal.configuration; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; - -/** - *

Constants

- *

- * Change description here. - * - * @author Johnny Miller (ι”ΊδΏŠ), email: johnnysviva@outlook.com - * @date 5/2/20 11:41 PM - **/ -@Slf4j -@Component -public class Constants { - public Constants(ProjectProperty projectProperty) { - REDIS_JWT_KEY_PREFIX = String.format("%s:jwt:", projectProperty.getProjectParentArtifactId()); - log.info("Initiated 'REDIS_JWT_KEY_PREFIX': {}", REDIS_JWT_KEY_PREFIX); - } - - /** - * Key prefix of JWT stored in Redis. - */ - public static String REDIS_JWT_KEY_PREFIX; - /** - * Token key of request header. - */ - public static final String REQUEST_TOKEN_KEY = "Authorization"; - /** - * Prefix of JWT. - */ - public static final String JWT_PREFIX = "Bearer "; - /** - * Star sign - */ - public static final String ASTERISK = "*"; - /** - * At sign - */ - public static final String AT_SIGN = "@"; -} diff --git a/api-gateway/src/main/java/com/jmsoftware/maf/apigateway/universal/configuration/ProjectProperty.java b/api-gateway/src/main/java/com/jmsoftware/maf/apigateway/universal/configuration/ProjectProperty.java index c20b032c..1dccd83a 100644 --- a/api-gateway/src/main/java/com/jmsoftware/maf/apigateway/universal/configuration/ProjectProperty.java +++ b/api-gateway/src/main/java/com/jmsoftware/maf/apigateway/universal/configuration/ProjectProperty.java @@ -3,6 +3,7 @@ import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; +import org.springframework.validation.annotation.Validated; /** *

ProjectProperty

@@ -13,7 +14,9 @@ * @date 2019-04-18 13:01 **/ @Data +@Validated @Component +@SuppressWarnings("jol") @ConfigurationProperties(prefix = "project.property") public class ProjectProperty { private String basePackage; diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/AuthCenterApplication.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/AuthCenterApplication.java index 98721033..34fcd833 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/AuthCenterApplication.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/AuthCenterApplication.java @@ -1,6 +1,6 @@ package com.jmsoftware.maf.authcenter; -import com.jmsoftware.maf.authcenter.universal.configuration.ProjectProperty; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import com.jmsoftware.maf.springbootstarter.helper.IpHelper; import lombok.extern.slf4j.Slf4j; import lombok.val; @@ -27,11 +27,11 @@ @SpringBootApplication public class AuthCenterApplication { private static final String LINE_SEPARATOR = System.lineSeparator(); - private static ProjectProperty projectProperty; + private static MafProjectProperty mafProjectProperty; private static IpHelper ipHelper; - public AuthCenterApplication(ProjectProperty projectProperty, IpHelper ipHelper) { - AuthCenterApplication.projectProperty = projectProperty; + public AuthCenterApplication(MafProjectProperty projectProperty, IpHelper ipHelper) { + AuthCenterApplication.mafProjectProperty = projectProperty; AuthCenterApplication.ipHelper = ipHelper; } @@ -41,12 +41,12 @@ public static void main(String[] args) { val endInstant = Instant.now(); val duration = Duration.between(startInstant, endInstant); log.info("πŸ₯³ Congratulations! πŸŽ‰"); - log.info("πŸ–₯ {}@{} started!", projectProperty.getProjectArtifactId(), projectProperty.getVersion()); - log.info("βš™οΈ Environment: {}", projectProperty.getEnvironment()); + log.info("πŸ–₯ {}@{} started!", mafProjectProperty.getProjectArtifactId(), mafProjectProperty.getVersion()); + log.info("βš™οΈ Environment: {}", mafProjectProperty.getEnvironment()); log.info("⏳ Deployment duration: {} seconds ({} ms)", duration.getSeconds(), duration.toMillis()); log.info("⏰ App started at {} (timezone - {})", endInstant, TimeZone.getDefault().getDisplayName()); log.info("{} App running at{} - Local: http://localhost:{}{}/{} - Network: http://{}:{}{}/", - LINE_SEPARATOR, LINE_SEPARATOR, ipHelper.getServerPort(), projectProperty.getContextPath(), - LINE_SEPARATOR, ipHelper.getPublicIp(), ipHelper.getServerPort(), projectProperty.getContextPath()); + LINE_SEPARATOR, LINE_SEPARATOR, ipHelper.getServerPort(), mafProjectProperty.getContextPath(), + LINE_SEPARATOR, ipHelper.getPublicIp(), ipHelper.getServerPort(), mafProjectProperty.getContextPath()); } } diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/permission/service/impl/PermissionServiceImpl.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/permission/service/impl/PermissionServiceImpl.java index 1d7b4071..0e9cf93f 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/permission/service/impl/PermissionServiceImpl.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/permission/service/impl/PermissionServiceImpl.java @@ -10,13 +10,13 @@ import com.jmsoftware.maf.authcenter.permission.mapper.PermissionMapper; import com.jmsoftware.maf.authcenter.permission.service.PermissionService; import com.jmsoftware.maf.authcenter.role.service.RoleService; -import com.jmsoftware.maf.authcenter.universal.configuration.ProjectProperty; import com.jmsoftware.maf.common.bean.ResponseBodyBean; import com.jmsoftware.maf.common.domain.authcenter.permission.GetPermissionListByRoleIdListPayload; import com.jmsoftware.maf.common.domain.authcenter.permission.GetPermissionListByRoleIdListResponse; import com.jmsoftware.maf.common.domain.authcenter.permission.PermissionType; import com.jmsoftware.maf.common.domain.springbootstarter.HttpApiResourcesResponse; import com.jmsoftware.maf.common.exception.BusinessException; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -44,7 +44,7 @@ public class PermissionServiceImpl extends ServiceImpl implements PermissionService { private final RoleService roleService; private final DiscoveryClient discoveryClient; - private final ProjectProperty projectProperty; + private final MafProjectProperty mafProjectProperty; private final RestTemplate restTemplate; @Override @@ -84,8 +84,8 @@ public GetServicesInfoResponse getServicesInfo() throws BusinessException { log.info("Getting service info from Service ID list: {}", serviceIdList); val response = new GetServicesInfoResponse(); val mapper = new ObjectMapper(); - val ignoredServiceIdList = Lists.newArrayList(projectProperty.getProjectArtifactId(), - "api-gateway", "spring-boot-admin"); + val ignoredServiceIdList = Lists.newArrayList(mafProjectProperty.getProjectArtifactId(), + "api-gateway", "spring-boot-admin"); log.info("Ignored service ID list: {}", ignoredServiceIdList); for (String serviceId : serviceIdList) { if (ignoredServiceIdList.contains(serviceId)) { diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/JwtConfiguration.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/JwtConfiguration.java index 77dc014f..581c92a7 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/JwtConfiguration.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/JwtConfiguration.java @@ -1,5 +1,6 @@ package com.jmsoftware.maf.authcenter.universal.configuration; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -26,11 +27,11 @@ public class JwtConfiguration { */ private String jwtRedisKeyPrefix; - public JwtConfiguration(ProjectProperty projectProperty) { - this.signingKey = String.format("%s %s", projectProperty.getProjectParentArtifactId(), projectProperty.getVersion()); + public JwtConfiguration(MafProjectProperty mafProjectProperty) { + this.signingKey = String.format("%s %s", mafProjectProperty.getProjectParentArtifactId(), mafProjectProperty.getVersion()); log.info("Initiated JWT signing key: {}. The specified key byte array is {} bits", this.signingKey, this.signingKey.getBytes(StandardCharsets.UTF_8).length * 8); - jwtRedisKeyPrefix = String.format("%s:jwt:", projectProperty.getProjectParentArtifactId()); + jwtRedisKeyPrefix = String.format("%s:jwt:", mafProjectProperty.getProjectParentArtifactId()); log.warn("Initiated 'jwtRedisKeyPrefix': {}", jwtRedisKeyPrefix); } diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/ProjectProperty.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/ProjectProperty.java deleted file mode 100644 index 1835675d..00000000 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/ProjectProperty.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jmsoftware.maf.authcenter.universal.configuration; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - *

ProjectProperty

- *

- * Change description here. - * - * @author Johnny Miller (ι”ΊδΏŠ), email: johnnysviva@outlook.com - * @date 2019-04-18 13:01 - **/ -@Data -@Component -@ConfigurationProperties(prefix = "project.property") -public class ProjectProperty { - private String basePackage; - private String contextPath; - private String groupId; - private String projectParentArtifactId; - private String projectArtifactId; - private String version; - private String description; - private String jdkVersion; - private String environment; - private String url; - private String inceptionYear; - private String organizationName; - private String organizationUrl; - private String issueManagementSystem; - private String issueManagementUrl; - private String developerName; - private String developerEmail; - private String developerUrl; -} diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/Swagger2Configuration.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/Swagger2Configuration.java index 46cd83f6..9f68c6c4 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/Swagger2Configuration.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/configuration/Swagger2Configuration.java @@ -1,5 +1,6 @@ package com.jmsoftware.maf.authcenter.universal.configuration; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import lombok.RequiredArgsConstructor; import lombok.val; import org.springframework.context.annotation.Bean; @@ -26,31 +27,31 @@ @EnableSwagger2 @RequiredArgsConstructor public class Swagger2Configuration { - private final ProjectProperty projectProperty; + private final MafProjectProperty mafProjectProperty; @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() - .apis(RequestHandlerSelectors.basePackage(projectProperty.getBasePackage())) + .apis(RequestHandlerSelectors.basePackage(mafProjectProperty.getBasePackage())) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { - val projectArtifactId = projectProperty.getProjectArtifactId(); - val version = projectProperty.getVersion(); - val developerEmail = projectProperty.getDeveloperEmail(); - val developerUrl = projectProperty.getDeveloperUrl(); + val projectArtifactId = mafProjectProperty.getProjectArtifactId(); + val version = mafProjectProperty.getVersion(); + val developerEmail = mafProjectProperty.getDeveloperEmail(); + val developerUrl = mafProjectProperty.getDeveloperUrl(); return new ApiInfoBuilder() .title(String.format("API for %s@%s", projectArtifactId, version)) .description(String.format("%s Artifact ID: %s Environment: %s", - projectProperty.getDescription(), + mafProjectProperty.getDescription(), projectArtifactId, - projectProperty.getEnvironment())) + mafProjectProperty.getEnvironment())) .contact(new Contact(String.format("%s, email: %s Home page: %s", - projectProperty.getDeveloperName(), + mafProjectProperty.getDeveloperName(), developerEmail, developerUrl), developerUrl, developerEmail)) diff --git a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/service/impl/CommonServiceImpl.java b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/service/impl/CommonServiceImpl.java index 4524b22c..98db6dc9 100644 --- a/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/service/impl/CommonServiceImpl.java +++ b/auth-center/src/main/java/com/jmsoftware/maf/authcenter/universal/service/impl/CommonServiceImpl.java @@ -1,8 +1,8 @@ package com.jmsoftware.maf.authcenter.universal.service.impl; -import com.jmsoftware.maf.authcenter.universal.configuration.ProjectProperty; import com.jmsoftware.maf.authcenter.universal.service.CommonService; import com.jmsoftware.maf.common.domain.ValidationTestPayload; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -27,12 +27,12 @@ @Service @RequiredArgsConstructor public class CommonServiceImpl implements CommonService { - private final ProjectProperty projectProperty; + private final MafProjectProperty mafProjectProperty; @Override public Map getApplicationInfo() { var map = new HashMap(16); - var fieldsInfo = getFieldsInfo(projectProperty); + var fieldsInfo = getFieldsInfo(mafProjectProperty); fieldsInfo.forEach(fieldInfo -> { var type = fieldInfo.get("type"); if ("class java.lang.String".equals(type)) { diff --git a/auth-center/src/main/resources/application.yml b/auth-center/src/main/resources/application.yml index 87464206..1a1db995 100644 --- a/auth-center/src/main/resources/application.yml +++ b/auth-center/src/main/resources/application.yml @@ -79,8 +79,8 @@ logging: level: com.jmsoftware: DEBUG -project: - property: +maf: + project-property: base-package: @project.groupId@ context-path: group-id: @project.groupId@ @@ -99,15 +99,6 @@ project: developer-name: @developerName@ developer-email: @developerEmail@ developer-url: @developerUrl@ - -# Customize JWT configuration for development environment. -jwt: - configuration: - # an hour - ttl: 3600000 - ttl-for-remember-me: 604800000 - -maf: configuration: ignored-url: pattern: @@ -120,3 +111,10 @@ maf: - "/webjars/**" - "/doc.html" included-package-for-http-api-scan: ${project.property.base-package} + +# Customize JWT configuration for development environment. +jwt: + configuration: + # an hour + ttl: 3600000 + ttl-for-remember-me: 604800000 diff --git a/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/ExerciseMisApplication.java b/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/ExerciseMisApplication.java index 612f512f..e81c9cfe 100644 --- a/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/ExerciseMisApplication.java +++ b/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/ExerciseMisApplication.java @@ -1,6 +1,6 @@ package com.jmsoftware.maf.exercisemis; -import com.jmsoftware.maf.exercisemis.universal.configuration.ProjectProperty; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import com.jmsoftware.maf.springbootstarter.helper.IpHelper; import lombok.extern.slf4j.Slf4j; import lombok.val; @@ -27,11 +27,11 @@ @SpringBootApplication public class ExerciseMisApplication { private static final String LINE_SEPARATOR = System.lineSeparator(); - private static ProjectProperty projectProperty; + private static MafProjectProperty mafProjectProperty; private static IpHelper ipHelper; - public ExerciseMisApplication(ProjectProperty projectProperty, IpHelper ipHelper) { - ExerciseMisApplication.projectProperty = projectProperty; + public ExerciseMisApplication(MafProjectProperty mafProjectProperty, IpHelper ipHelper) { + ExerciseMisApplication.mafProjectProperty = mafProjectProperty; ExerciseMisApplication.ipHelper = ipHelper; } @@ -41,12 +41,12 @@ public static void main(String[] args) { val endInstant = Instant.now(); val duration = Duration.between(startInstant, endInstant); log.info("πŸ₯³ Congratulations! πŸŽ‰"); - log.info("πŸ–₯ {}@{} started!", projectProperty.getProjectArtifactId(), projectProperty.getVersion()); - log.info("βš™οΈ Environment: {}", projectProperty.getEnvironment()); + log.info("πŸ–₯ {}@{} started!", mafProjectProperty.getProjectArtifactId(), mafProjectProperty.getVersion()); + log.info("βš™οΈ Environment: {}", mafProjectProperty.getEnvironment()); log.info("⏳ Deployment duration: {} seconds ({} ms)", duration.getSeconds(), duration.toMillis()); log.info("⏰ App started at {} (timezone - {})", endInstant, TimeZone.getDefault().getDisplayName()); log.info("{} App running at{} - Local: http://localhost:{}{}/{} - Network: http://{}:{}/{}", - LINE_SEPARATOR, LINE_SEPARATOR, ipHelper.getServerPort(), projectProperty.getContextPath(), - LINE_SEPARATOR, ipHelper.getPublicIp(), ipHelper.getServerPort(), projectProperty.getContextPath()); + LINE_SEPARATOR, LINE_SEPARATOR, ipHelper.getServerPort(), mafProjectProperty.getContextPath(), + LINE_SEPARATOR, ipHelper.getPublicIp(), ipHelper.getServerPort(), mafProjectProperty.getContextPath()); } } diff --git a/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/universal/configuration/ProjectProperty.java b/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/universal/configuration/ProjectProperty.java deleted file mode 100644 index e56f4a52..00000000 --- a/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/universal/configuration/ProjectProperty.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.jmsoftware.maf.exercisemis.universal.configuration; - -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - *

ProjectProperty

- *

- * Change description here. - * - * @author Johnny Miller (ι”ΊδΏŠ), email: johnnysviva@outlook.com - * @date 2019-04-18 13:01 - **/ -@Slf4j -@Data -@Component -@ConfigurationProperties(prefix = "project.property") -public class ProjectProperty { - private String basePackage; - private String contextPath; - private String groupId; - private String projectParentArtifactId; - private String projectArtifactId; - private String version; - private String description; - private String jdkVersion; - private String environment; - private String url; - private String inceptionYear; - private String organizationName; - private String organizationUrl; - private String issueManagementSystem; - private String issueManagementUrl; - private String developerName; - private String developerEmail; - private String developerUrl; -} diff --git a/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/universal/configuration/Swagger2Configuration.java b/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/universal/configuration/Swagger2Configuration.java index d35337db..7f6f7bf5 100644 --- a/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/universal/configuration/Swagger2Configuration.java +++ b/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/universal/configuration/Swagger2Configuration.java @@ -1,5 +1,6 @@ package com.jmsoftware.maf.exercisemis.universal.configuration; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import lombok.RequiredArgsConstructor; import lombok.val; import org.springframework.context.annotation.Bean; @@ -26,31 +27,31 @@ @EnableSwagger2 @RequiredArgsConstructor public class Swagger2Configuration { - private final ProjectProperty projectProperty; + private final MafProjectProperty mafProjectProperty; @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() - .apis(RequestHandlerSelectors.basePackage(projectProperty.getBasePackage())) + .apis(RequestHandlerSelectors.basePackage(mafProjectProperty.getBasePackage())) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { - val projectArtifactId = projectProperty.getProjectArtifactId(); - val version = projectProperty.getVersion(); - val developerEmail = projectProperty.getDeveloperEmail(); - val developerUrl = projectProperty.getDeveloperUrl(); + val projectArtifactId = mafProjectProperty.getProjectArtifactId(); + val version = mafProjectProperty.getVersion(); + val developerEmail = mafProjectProperty.getDeveloperEmail(); + val developerUrl = mafProjectProperty.getDeveloperUrl(); return new ApiInfoBuilder() .title(String.format("API for %s@%s", projectArtifactId, version)) .description(String.format("%s Artifact ID: %s Environment: %s", - projectProperty.getDescription(), + mafProjectProperty.getDescription(), projectArtifactId, - projectProperty.getEnvironment())) + mafProjectProperty.getEnvironment())) .contact(new Contact(String.format("%s, email: %s Home page: %s", - projectProperty.getDeveloperName(), + mafProjectProperty.getDeveloperName(), developerEmail, developerUrl), developerUrl, developerEmail)) diff --git a/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/universal/service/impl/CommonServiceImpl.java b/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/universal/service/impl/CommonServiceImpl.java index ba6890e5..6f896ec5 100644 --- a/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/universal/service/impl/CommonServiceImpl.java +++ b/exercise-mis/src/main/java/com/jmsoftware/maf/exercisemis/universal/service/impl/CommonServiceImpl.java @@ -1,8 +1,8 @@ package com.jmsoftware.maf.exercisemis.universal.service.impl; import com.jmsoftware.maf.common.domain.ValidationTestPayload; -import com.jmsoftware.maf.exercisemis.universal.configuration.ProjectProperty; import com.jmsoftware.maf.exercisemis.universal.service.CommonService; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -27,12 +27,12 @@ @Service @RequiredArgsConstructor public class CommonServiceImpl implements CommonService { - private final ProjectProperty projectProperty; + private final MafProjectProperty mafProjectProperty; @Override public Map getApplicationInfo() { var map = new HashMap(16); - var fieldsInfo = getFieldsInfo(projectProperty); + var fieldsInfo = getFieldsInfo(mafProjectProperty); fieldsInfo.forEach(fieldInfo -> { var type = fieldInfo.get("type"); if ("class java.lang.String".equals(type)) { diff --git a/exercise-mis/src/main/resources/application.yml b/exercise-mis/src/main/resources/application.yml index 21dbff0f..0b6bad56 100644 --- a/exercise-mis/src/main/resources/application.yml +++ b/exercise-mis/src/main/resources/application.yml @@ -79,8 +79,8 @@ logging: level: com.jmsoftware: DEBUG -project: - property: +maf: + project-property: base-package: @project.groupId@ context-path: group-id: @project.groupId@ @@ -99,8 +99,6 @@ project: developer-name: @developerName@ developer-email: @developerEmail@ developer-url: @developerUrl@ - -maf: configuration: ignored-url: pattern: diff --git a/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/MuscleMisApplication.java b/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/MuscleMisApplication.java index 3832c133..cd38c47f 100644 --- a/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/MuscleMisApplication.java +++ b/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/MuscleMisApplication.java @@ -1,6 +1,6 @@ package com.jmsoftware.maf.musclemis; -import com.jmsoftware.maf.musclemis.universal.configuration.ProjectProperty; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import com.jmsoftware.maf.springbootstarter.helper.IpHelper; import lombok.extern.slf4j.Slf4j; import lombok.val; @@ -27,11 +27,11 @@ @SpringBootApplication public class MuscleMisApplication { private static final String LINE_SEPARATOR = System.lineSeparator(); - private static ProjectProperty projectProperty; + private static MafProjectProperty mafProjectProperty; private static IpHelper ipHelper; - public MuscleMisApplication(ProjectProperty projectProperty, IpHelper ipHelper) { - MuscleMisApplication.projectProperty = projectProperty; + public MuscleMisApplication(MafProjectProperty mafProjectProperty, IpHelper ipHelper) { + MuscleMisApplication.mafProjectProperty = mafProjectProperty; MuscleMisApplication.ipHelper = ipHelper; } @@ -41,12 +41,12 @@ public static void main(String[] args) { val endInstant = Instant.now(); val duration = Duration.between(startInstant, endInstant); log.info("πŸ₯³ Congratulations! πŸŽ‰"); - log.info("πŸ–₯ {}@{} started!", projectProperty.getProjectArtifactId(), projectProperty.getVersion()); - log.info("βš™οΈ Environment: {}", projectProperty.getEnvironment()); + log.info("πŸ–₯ {}@{} started!", mafProjectProperty.getProjectArtifactId(), mafProjectProperty.getVersion()); + log.info("βš™οΈ Environment: {}", mafProjectProperty.getEnvironment()); log.info("⏳ Deployment duration: {} seconds ({} ms)", duration.getSeconds(), duration.toMillis()); log.info("⏰ App started at {} (timezone - {})", endInstant, TimeZone.getDefault().getDisplayName()); log.info("{} App running at{} - Local: http://localhost:{}{}/{} - Network: http://{}:{}/{}", - LINE_SEPARATOR, LINE_SEPARATOR, ipHelper.getServerPort(), projectProperty.getContextPath(), - LINE_SEPARATOR, ipHelper.getPublicIp(), ipHelper.getServerPort(), projectProperty.getContextPath()); + LINE_SEPARATOR, LINE_SEPARATOR, ipHelper.getServerPort(), mafProjectProperty.getContextPath(), + LINE_SEPARATOR, ipHelper.getPublicIp(), ipHelper.getServerPort(), mafProjectProperty.getContextPath()); } } diff --git a/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/universal/configuration/ProjectProperty.java b/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/universal/configuration/ProjectProperty.java deleted file mode 100644 index e1429d61..00000000 --- a/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/universal/configuration/ProjectProperty.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jmsoftware.maf.musclemis.universal.configuration; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - *

ProjectProperty

- *

- * Change description here. - * - * @author Johnny Miller (ι”ΊδΏŠ), email: johnnysviva@outlook.com - * @date 2019-04-18 13:01 - **/ -@Data -@Component -@ConfigurationProperties(prefix = "project.property") -public class ProjectProperty { - private String basePackage; - private String contextPath; - private String groupId; - private String projectParentArtifactId; - private String projectArtifactId; - private String version; - private String description; - private String jdkVersion; - private String environment; - private String url; - private String inceptionYear; - private String organizationName; - private String organizationUrl; - private String issueManagementSystem; - private String issueManagementUrl; - private String developerName; - private String developerEmail; - private String developerUrl; -} diff --git a/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/universal/configuration/Swagger2Configuration.java b/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/universal/configuration/Swagger2Configuration.java index fa848d0f..fc724022 100644 --- a/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/universal/configuration/Swagger2Configuration.java +++ b/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/universal/configuration/Swagger2Configuration.java @@ -1,5 +1,6 @@ package com.jmsoftware.maf.musclemis.universal.configuration; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import lombok.RequiredArgsConstructor; import lombok.val; import org.springframework.context.annotation.Bean; @@ -26,31 +27,31 @@ @EnableSwagger2 @RequiredArgsConstructor public class Swagger2Configuration { - private final ProjectProperty projectProperty; + private final MafProjectProperty mafProjectProperty; @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() - .apis(RequestHandlerSelectors.basePackage(projectProperty.getBasePackage())) + .apis(RequestHandlerSelectors.basePackage(mafProjectProperty.getBasePackage())) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { - val projectArtifactId = projectProperty.getProjectArtifactId(); - val version = projectProperty.getVersion(); - val developerEmail = projectProperty.getDeveloperEmail(); - val developerUrl = projectProperty.getDeveloperUrl(); + val projectArtifactId = mafProjectProperty.getProjectArtifactId(); + val version = mafProjectProperty.getVersion(); + val developerEmail = mafProjectProperty.getDeveloperEmail(); + val developerUrl = mafProjectProperty.getDeveloperUrl(); return new ApiInfoBuilder() .title(String.format("API for %s@%s", projectArtifactId, version)) .description(String.format("%s Artifact ID: %s Environment: %s", - projectProperty.getDescription(), + mafProjectProperty.getDescription(), projectArtifactId, - projectProperty.getEnvironment())) + mafProjectProperty.getEnvironment())) .contact(new Contact(String.format("%s, email: %s Home page: %s", - projectProperty.getDeveloperName(), + mafProjectProperty.getDeveloperName(), developerEmail, developerUrl), developerUrl, developerEmail)) diff --git a/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/universal/service/impl/CommonServiceImpl.java b/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/universal/service/impl/CommonServiceImpl.java index 2df0daa1..ce2b807b 100644 --- a/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/universal/service/impl/CommonServiceImpl.java +++ b/muscle-mis/src/main/java/com/jmsoftware/maf/musclemis/universal/service/impl/CommonServiceImpl.java @@ -1,8 +1,8 @@ package com.jmsoftware.maf.musclemis.universal.service.impl; import com.jmsoftware.maf.common.domain.ValidationTestPayload; -import com.jmsoftware.maf.musclemis.universal.configuration.ProjectProperty; import com.jmsoftware.maf.musclemis.universal.service.CommonService; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -27,12 +27,12 @@ @Service @RequiredArgsConstructor public class CommonServiceImpl implements CommonService { - private final ProjectProperty projectProperty; + private final MafProjectProperty mafProjectProperty; @Override public Map getApplicationInfo() { var map = new HashMap(16); - var fieldsInfo = getFieldsInfo(projectProperty); + var fieldsInfo = getFieldsInfo(mafProjectProperty); fieldsInfo.forEach(fieldInfo -> { var type = fieldInfo.get("type"); if ("class java.lang.String".equals(type)) { diff --git a/muscle-mis/src/main/resources/application.yml b/muscle-mis/src/main/resources/application.yml index ba8c6145..c3513cfe 100644 --- a/muscle-mis/src/main/resources/application.yml +++ b/muscle-mis/src/main/resources/application.yml @@ -67,8 +67,8 @@ logging: level: com.jmsoftware: DEBUG -project: - property: +maf: + project-property: base-package: @project.groupId@ context-path: group-id: @project.groupId@ @@ -87,8 +87,6 @@ project: developer-name: @developerName@ developer-email: @developerEmail@ developer-url: @developerUrl@ - -maf: configuration: ignored-url: pattern: diff --git a/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/ServiceRegistryApplication.java b/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/ServiceRegistryApplication.java index 105224ec..5a276138 100644 --- a/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/ServiceRegistryApplication.java +++ b/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/ServiceRegistryApplication.java @@ -1,6 +1,6 @@ package com.jmsoftware.maf.serviceregistry; -import com.jmsoftware.maf.serviceregistry.universal.configuration.ProjectProperty; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import com.jmsoftware.maf.springbootstarter.helper.IpHelper; import lombok.extern.slf4j.Slf4j; import lombok.val; @@ -25,11 +25,11 @@ @SpringBootApplication public class ServiceRegistryApplication { private static final String LINE_SEPARATOR = System.lineSeparator(); - private static ProjectProperty projectProperty; + private static MafProjectProperty mafProjectProperty; private static IpHelper ipHelper; - public ServiceRegistryApplication(ProjectProperty projectProperty, IpHelper ipHelper) { - ServiceRegistryApplication.projectProperty = projectProperty; + public ServiceRegistryApplication(MafProjectProperty mafProjectProperty, IpHelper ipHelper) { + ServiceRegistryApplication.mafProjectProperty = mafProjectProperty; ServiceRegistryApplication.ipHelper = ipHelper; } @@ -39,12 +39,12 @@ public static void main(String[] args) { val endInstant = Instant.now(); val duration = Duration.between(startInstant, endInstant); log.info("πŸ₯³ Congratulations! πŸŽ‰"); - log.info("πŸ–₯ {}@{} started!", projectProperty.getProjectArtifactId(), projectProperty.getVersion()); - log.info("βš™οΈ Environment: {}", projectProperty.getEnvironment()); + log.info("πŸ–₯ {}@{} started!", mafProjectProperty.getProjectArtifactId(), mafProjectProperty.getVersion()); + log.info("βš™οΈ Environment: {}", mafProjectProperty.getEnvironment()); log.info("⏳ Deployment duration: {} seconds ({} ms)", duration.getSeconds(), duration.toMillis()); log.info("⏰ App started at {} (timezone - {})", endInstant, TimeZone.getDefault().getDisplayName()); log.info("{} App running at{} - Local: http://localhost:{}{}/{} - Network: http://{}:{}/{}", - LINE_SEPARATOR, LINE_SEPARATOR, ipHelper.getServerPort(), projectProperty.getContextPath(), - LINE_SEPARATOR, ipHelper.getPublicIp(), ipHelper.getServerPort(), projectProperty.getContextPath()); + LINE_SEPARATOR, LINE_SEPARATOR, ipHelper.getServerPort(), mafProjectProperty.getContextPath(), + LINE_SEPARATOR, ipHelper.getPublicIp(), ipHelper.getServerPort(), mafProjectProperty.getContextPath()); } } diff --git a/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/universal/configuration/ProjectProperty.java b/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/universal/configuration/ProjectProperty.java deleted file mode 100644 index cc4d2e29..00000000 --- a/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/universal/configuration/ProjectProperty.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jmsoftware.maf.serviceregistry.universal.configuration; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - *

ProjectProperty

- *

- * Change description here. - * - * @author Johnny Miller (ι”ΊδΏŠ), email: johnnysviva@outlook.com - * @date 2019-04-18 13:01 - **/ -@Data -@Component -@ConfigurationProperties(prefix = "project.property") -public class ProjectProperty { - private String basePackage; - private String contextPath; - private String groupId; - private String projectParentArtifactId; - private String projectArtifactId; - private String version; - private String description; - private String jdkVersion; - private String environment; - private String url; - private String inceptionYear; - private String organizationName; - private String organizationUrl; - private String issueManagementSystem; - private String issueManagementUrl; - private String developerName; - private String developerEmail; - private String developerUrl; -} diff --git a/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/universal/configuration/Swagger2Configuration.java b/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/universal/configuration/Swagger2Configuration.java index 1efbbcac..d2ab5726 100644 --- a/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/universal/configuration/Swagger2Configuration.java +++ b/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/universal/configuration/Swagger2Configuration.java @@ -1,5 +1,6 @@ package com.jmsoftware.maf.serviceregistry.universal.configuration; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import lombok.RequiredArgsConstructor; import lombok.val; import org.springframework.context.annotation.Bean; @@ -26,31 +27,31 @@ @EnableSwagger2 @RequiredArgsConstructor public class Swagger2Configuration { - private final ProjectProperty projectProperty; + private final MafProjectProperty mafProjectProperty; @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() - .apis(RequestHandlerSelectors.basePackage(projectProperty.getBasePackage())) + .apis(RequestHandlerSelectors.basePackage(mafProjectProperty.getBasePackage())) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { - val projectArtifactId = projectProperty.getProjectArtifactId(); - val version = projectProperty.getVersion(); - val developerEmail = projectProperty.getDeveloperEmail(); - val developerUrl = projectProperty.getDeveloperUrl(); + val projectArtifactId = mafProjectProperty.getProjectArtifactId(); + val version = mafProjectProperty.getVersion(); + val developerEmail = mafProjectProperty.getDeveloperEmail(); + val developerUrl = mafProjectProperty.getDeveloperUrl(); return new ApiInfoBuilder() .title(String.format("API for %s@%s", projectArtifactId, version)) .description(String.format("%s Artifact ID: %s Environment: %s", - projectProperty.getDescription(), + mafProjectProperty.getDescription(), projectArtifactId, - projectProperty.getEnvironment())) + mafProjectProperty.getEnvironment())) .contact(new Contact(String.format("%s, email: %s Home page: %s", - projectProperty.getDeveloperName(), + mafProjectProperty.getDeveloperName(), developerEmail, developerUrl), developerUrl, developerEmail)) diff --git a/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/universal/service/impl/CommonServiceImpl.java b/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/universal/service/impl/CommonServiceImpl.java index 129f6fb6..20e0f714 100644 --- a/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/universal/service/impl/CommonServiceImpl.java +++ b/service-registry/src/main/java/com/jmsoftware/maf/serviceregistry/universal/service/impl/CommonServiceImpl.java @@ -1,8 +1,8 @@ package com.jmsoftware.maf.serviceregistry.universal.service.impl; import com.jmsoftware.maf.common.domain.ValidationTestPayload; -import com.jmsoftware.maf.serviceregistry.universal.configuration.ProjectProperty; import com.jmsoftware.maf.serviceregistry.universal.service.CommonService; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -27,12 +27,12 @@ @Service @RequiredArgsConstructor public class CommonServiceImpl implements CommonService { - private final ProjectProperty projectProperty; + private final MafProjectProperty mafProjectProperty; @Override public Map getApplicationInfo() { var map = new HashMap(16); - var fieldsInfo = getFieldsInfo(projectProperty); + var fieldsInfo = getFieldsInfo(mafProjectProperty); fieldsInfo.forEach(fieldInfo -> { var type = fieldInfo.get("type"); if ("class java.lang.String".equals(type)) { diff --git a/service-registry/src/main/resources/application.yml b/service-registry/src/main/resources/application.yml index 6a3f808f..fe0e1a2b 100644 --- a/service-registry/src/main/resources/application.yml +++ b/service-registry/src/main/resources/application.yml @@ -27,8 +27,8 @@ logging: level: com.jmsoftware: DEBUG -project: - property: +maf: + project-property: base-package: @project.groupId@ context-path: group-id: @project.groupId@ @@ -47,10 +47,9 @@ project: developer-name: @developerName@ developer-email: @developerEmail@ developer-url: @developerUrl@ - -maf: configuration: ignored-url: pattern: - "/actuator/**" included-package-for-http-api-scan: ${project.property.base-package} + diff --git a/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/SpringBootAdminApplication.java b/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/SpringBootAdminApplication.java index df21d2a0..6cb3aca9 100644 --- a/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/SpringBootAdminApplication.java +++ b/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/SpringBootAdminApplication.java @@ -1,6 +1,6 @@ package com.jmsoftware.maf.springbootadmin; -import com.jmsoftware.maf.springbootadmin.universal.configuration.ProjectProperty; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import com.jmsoftware.maf.springbootstarter.helper.IpHelper; import de.codecentric.boot.admin.server.config.EnableAdminServer; import lombok.extern.slf4j.Slf4j; @@ -27,11 +27,11 @@ @SpringBootApplication public class SpringBootAdminApplication { private static final String LINE_SEPARATOR = System.lineSeparator(); - private static ProjectProperty projectProperty; + private static MafProjectProperty mafProjectProperty; private static IpHelper ipHelper; - public SpringBootAdminApplication(ProjectProperty projectProperty, IpHelper ipHelper) { - SpringBootAdminApplication.projectProperty = projectProperty; + public SpringBootAdminApplication(MafProjectProperty mafProjectProperty, IpHelper ipHelper) { + SpringBootAdminApplication.mafProjectProperty = mafProjectProperty; SpringBootAdminApplication.ipHelper = ipHelper; } @@ -41,12 +41,12 @@ public static void main(String[] args) { val endInstant = Instant.now(); val duration = Duration.between(startInstant, endInstant); log.info("πŸ₯³ Congratulations! πŸŽ‰"); - log.info("πŸ–₯ {}@{} started!", projectProperty.getProjectArtifactId(), projectProperty.getVersion()); - log.info("βš™οΈ Environment: {}", projectProperty.getEnvironment()); + log.info("πŸ–₯ {}@{} started!", mafProjectProperty.getProjectArtifactId(), mafProjectProperty.getVersion()); + log.info("βš™οΈ Environment: {}", mafProjectProperty.getEnvironment()); log.info("⏳ Deployment duration: {} seconds ({} ms)", duration.getSeconds(), duration.toMillis()); log.info("⏰ App started at {} (timezone - {})", endInstant, TimeZone.getDefault().getDisplayName()); log.info("{} App running at{} - Local: http://localhost:{}{}/{} - Network: http://{}:{}/{}", - LINE_SEPARATOR, LINE_SEPARATOR, ipHelper.getServerPort(), projectProperty.getContextPath(), - LINE_SEPARATOR, ipHelper.getPublicIp(), ipHelper.getServerPort(), projectProperty.getContextPath()); + LINE_SEPARATOR, LINE_SEPARATOR, ipHelper.getServerPort(), mafProjectProperty.getContextPath(), + LINE_SEPARATOR, ipHelper.getPublicIp(), ipHelper.getServerPort(), mafProjectProperty.getContextPath()); } } diff --git a/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/universal/configuration/ProjectProperty.java b/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/universal/configuration/ProjectProperty.java deleted file mode 100644 index 254c82da..00000000 --- a/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/universal/configuration/ProjectProperty.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.jmsoftware.maf.springbootadmin.universal.configuration; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -/** - *

ProjectProperty

- *

- * Change description here. - * - * @author Johnny Miller (ι”ΊδΏŠ), email: johnnysviva@outlook.com - * @date 2019-04-18 13:01 - **/ -@Data -@Component -@ConfigurationProperties(prefix = "project.property") -public class ProjectProperty { - private String basePackage; - private String contextPath; - private String groupId; - private String projectParentArtifactId; - private String projectArtifactId; - private String version; - private String description; - private String jdkVersion; - private String environment; - private String url; - private String inceptionYear; - private String organizationName; - private String organizationUrl; - private String issueManagementSystem; - private String issueManagementUrl; - private String developerName; - private String developerEmail; - private String developerUrl; -} diff --git a/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/universal/configuration/Swagger2Configuration.java b/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/universal/configuration/Swagger2Configuration.java index 0c639e80..29c2c425 100644 --- a/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/universal/configuration/Swagger2Configuration.java +++ b/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/universal/configuration/Swagger2Configuration.java @@ -1,5 +1,6 @@ package com.jmsoftware.maf.springbootadmin.universal.configuration; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import lombok.RequiredArgsConstructor; import lombok.val; import org.springframework.context.annotation.Bean; @@ -26,31 +27,31 @@ @EnableSwagger2 @RequiredArgsConstructor public class Swagger2Configuration { - private final ProjectProperty projectProperty; + private final MafProjectProperty mafProjectProperty; @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() - .apis(RequestHandlerSelectors.basePackage(projectProperty.getBasePackage())) + .apis(RequestHandlerSelectors.basePackage(mafProjectProperty.getBasePackage())) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { - val projectArtifactId = projectProperty.getProjectArtifactId(); - val version = projectProperty.getVersion(); - val developerEmail = projectProperty.getDeveloperEmail(); - val developerUrl = projectProperty.getDeveloperUrl(); + val projectArtifactId = mafProjectProperty.getProjectArtifactId(); + val version = mafProjectProperty.getVersion(); + val developerEmail = mafProjectProperty.getDeveloperEmail(); + val developerUrl = mafProjectProperty.getDeveloperUrl(); return new ApiInfoBuilder() .title(String.format("API for %s@%s", projectArtifactId, version)) .description(String.format("%s Artifact ID: %s Environment: %s", - projectProperty.getDescription(), + mafProjectProperty.getDescription(), projectArtifactId, - projectProperty.getEnvironment())) + mafProjectProperty.getEnvironment())) .contact(new Contact(String.format("%s, email: %s Home page: %s", - projectProperty.getDeveloperName(), + mafProjectProperty.getDeveloperName(), developerEmail, developerUrl), developerUrl, developerEmail)) diff --git a/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/universal/service/impl/CommonServiceImpl.java b/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/universal/service/impl/CommonServiceImpl.java index 7e6064f0..18fabaf6 100644 --- a/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/universal/service/impl/CommonServiceImpl.java +++ b/spring-boot-admin/src/main/java/com/jmsoftware/maf/springbootadmin/universal/service/impl/CommonServiceImpl.java @@ -1,8 +1,8 @@ package com.jmsoftware.maf.springbootadmin.universal.service.impl; import com.jmsoftware.maf.common.domain.ValidationTestPayload; -import com.jmsoftware.maf.springbootadmin.universal.configuration.ProjectProperty; import com.jmsoftware.maf.springbootadmin.universal.service.CommonService; +import com.jmsoftware.maf.springbootstarter.configuration.MafProjectProperty; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -27,12 +27,12 @@ @Service @RequiredArgsConstructor public class CommonServiceImpl implements CommonService { - private final ProjectProperty projectProperty; + private final MafProjectProperty mafProjectProperty; @Override public Map getApplicationInfo() { var map = new HashMap(16); - var fieldsInfo = getFieldsInfo(projectProperty); + var fieldsInfo = getFieldsInfo(mafProjectProperty); fieldsInfo.forEach(fieldInfo -> { var type = fieldInfo.get("type"); if ("class java.lang.String".equals(type)) { diff --git a/spring-boot-admin/src/main/resources/application.yml b/spring-boot-admin/src/main/resources/application.yml index 4c54d8b4..15074be3 100644 --- a/spring-boot-admin/src/main/resources/application.yml +++ b/spring-boot-admin/src/main/resources/application.yml @@ -42,8 +42,8 @@ logging: level: com.jmsoftware: DEBUG -project: - property: +maf: + project-property: base-package: @project.groupId@ context-path: group-id: @project.groupId@ @@ -62,8 +62,6 @@ project: developer-name: @developerName@ developer-email: @developerEmail@ developer-url: @developerUrl@ - -maf: configuration: ignored-url: pattern: @@ -76,3 +74,4 @@ maf: - "/webjars/**" - "/doc.html" included-package-for-http-api-scan: ${project.property.base-package} + diff --git a/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/MafAutoConfiguration.java b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/MafAutoConfiguration.java index ab98f7d0..81792556 100644 --- a/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/MafAutoConfiguration.java +++ b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/MafAutoConfiguration.java @@ -118,4 +118,10 @@ public HttpApiResourceRemoteApiController httpApiResourceRemoteController(MafCon log.warn("Initial bean: {}", HttpApiResourceRemoteApiController.class.getSimpleName()); return new HttpApiResourceRemoteApiController(mafConfiguration, httpApiScanHelper); } + + @Bean + public MafProjectProperty mafProjectProperty() { + log.warn("Initial bean: {}", MafProjectProperty.class.getSimpleName()); + return new MafProjectProperty(); + } } diff --git a/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/MafProjectProperty.java b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/MafProjectProperty.java new file mode 100644 index 00000000..81c0afef --- /dev/null +++ b/spring-boot-starter/src/main/java/com/jmsoftware/maf/springbootstarter/configuration/MafProjectProperty.java @@ -0,0 +1,103 @@ +package com.jmsoftware.maf.springbootstarter.configuration; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotBlank; + +/** + *

MafProjectProperty

+ *

+ * M&F project property, containing the basic constants of the project. + * + * @author Johnny Miller (ι”ΊδΏŠ), email: johnnysviva@outlook.com, date: 12/29/2020 12:57 PM + */ +@Data +@Validated +@Component +@SuppressWarnings("jol") +@ConfigurationProperties(prefix = "maf.project-property") +public class MafProjectProperty { + /** + * The Base package. + */ + @NotBlank + private String basePackage; + /** + * The Context path. + */ + private String contextPath; + /** + * The Group id. + */ + @NotBlank + private String groupId; + /** + * The Project parent artifact id. + */ + @NotBlank + private String projectParentArtifactId; + /** + * The Project artifact id. + */ + @NotBlank + private String projectArtifactId; + /** + * The Version. + */ + @NotBlank + private String version; + /** + * The Description. + */ + @NotBlank + private String description; + /** + * The Jdk version. + */ + @NotBlank + private String jdkVersion; + /** + * The Environment. + */ + @NotBlank + private String environment; + /** + * The Url. + */ + private String url; + /** + * The Inception year. + */ + private String inceptionYear; + /** + * The Organization name. + */ + private String organizationName; + /** + * The Organization url. + */ + private String organizationUrl; + /** + * The Issue management system. + */ + private String issueManagementSystem; + /** + * The Issue management url. + */ + private String issueManagementUrl; + /** + * The Developer name. + */ + private String developerName; + /** + * The Developer email. + */ + private String developerEmail; + /** + * The Developer url. + */ + private String developerUrl; +}