Skip to content

Commit

Permalink
Add oracle spring profile with JDBC URL for local
Browse files Browse the repository at this point in the history
  • Loading branch information
mauvaisetroupe committed Nov 25, 2023
1 parent 2fc7e44 commit 6faf179
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 6 deletions.
9 changes: 9 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{ "version": "0.2.0", "configurations": [

{
"type": "java",
"name": "Launch MXFileSerializer",
Expand All @@ -22,6 +23,14 @@
"projectName": "ea-design-it",
"vmArgs": " -Dspring.profiles.active=prod"
},
{
"type": "java",
"name": "Launch EaDesignItApp DEV ORACLE",
"request": "launch",
"mainClass": "com.mauvaisetroupe.eadesignit.EaDesignItApp",
"projectName": "ea-design-it",
"vmArgs": " -Dspring.profiles.active=dev,oracle"
},
{
"type": "java",
"name": "Debug (Launch)",
Expand Down
13 changes: 10 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<profile.no-liquibase/>
<profile.test/>
<profile.tls/>
<profile.oracle/>
<properties-maven-plugin.version>1.2.0</properties-maven-plugin.version>
<sonar-maven-plugin.version>3.10.0.2594</sonar-maven-plugin.version>
<spotless-maven-plugin.version>2.40.0</spotless-maven-plugin.version>
Expand Down Expand Up @@ -884,7 +885,7 @@
</activation>
<properties>
<!-- default Spring profiles -->
<spring.profiles.active>dev${profile.tls}${profile.no-liquibase}</spring.profiles.active>
<spring.profiles.active>dev${profile.tls}${profile.no-liquibase}${profile.oracle}</spring.profiles.active>
<profile.test>testdev</profile.test>
<liquibase-plugin.hibernate-dialect>org.hibernate.dialect.H2Dialect</liquibase-plugin.hibernate-dialect>
<liquibase-plugin.driver>org.h2.Driver</liquibase-plugin.driver>
Expand Down Expand Up @@ -1037,7 +1038,7 @@
<id>prod</id>
<properties>
<!-- default Spring profiles -->
<spring.profiles.active>prod${profile.api-docs}${profile.tls}${profile.e2e}${profile.no-liquibase}</spring.profiles.active>
<spring.profiles.active>prod${profile.api-docs}${profile.tls}${profile.e2e}${profile.no-liquibase}${profile.oracle}</spring.profiles.active>
<profile.test>testprod</profile.test>
<liquibase-plugin.hibernate-dialect>org.hibernate.dialect.PostgreSQLDialect</liquibase-plugin.hibernate-dialect>
<liquibase-plugin.driver>org.postgresql.Driver</liquibase-plugin.driver>
Expand Down Expand Up @@ -1130,12 +1131,18 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>oracle</id>
<properties>
<profile.oracle>,oracle</profile.oracle>
</properties>
</profile>
<profile>
<id>tls</id>
<properties>
<profile.tls>,tls</profile.tls>
</properties>
</profile>
</profile>
<profile>
<id>war</id>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
@Configuration
public class WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer<WebServerFactory> {

private static final String ORACLE = "oracle";

private final Logger log = LoggerFactory.getLogger(WebConfigurer.class);

private final Environment env;
Expand All @@ -47,7 +49,9 @@ public void onStartup(ServletContext servletContext) throws ServletException {
}

if (env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT))) {
initH2Console(servletContext);
if (!env.acceptsProfiles(Profiles.of(ORACLE))) {
initH2Console(servletContext);
}
}
log.info("Web application fully configured");
}
Expand Down
10 changes: 9 additions & 1 deletion src/main/resources/config/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ logging:
level:
ROOT: INFO
tech.jhipster: INFO
org.hibernate.SQL: INFO
org.hibernate.SQL: DEBUG
com.mauvaisetroupe.eadesignit: INFO
org.hibernate.type.descriptor.sql.BasicBinder: INFO

Expand Down Expand Up @@ -59,6 +59,14 @@ spring:
server:
port: 8080

management:
endpoint:
env:
show-values: when_authorized
configprops:
show-values: when_authorized
additionalKeysToSanitize: password,secret

# ===================================================================
# JHipster specific properties
#
Expand Down
17 changes: 17 additions & 0 deletions src/main/resources/config/application-oracle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:oracle:thin:@localhost:1521:ORCLCDB
username: EADesignIt
password: EADesignIt
hikari:
poolName: Hikari
auto-commit: false
jpa:
properties:
# when schema not writen in SQL order, random bug : rlation ´flow' does not exist
hibernate.default_schema:
h2:
console:
# disable spring boot built-in h2-console since we start it manually with correct configuration
enabled: false
3 changes: 3 additions & 0 deletions src/main/webapp/app/core/jhi-navbar/jhi-navbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export default defineComponent({

const openAPIEnabled = computed(() => store.activeProfiles.indexOf('api-docs') > -1);
const inProduction = computed(() => store.activeProfiles.indexOf('prod') > -1);
const h2Database = computed(() => store.activeProfiles.indexOf('oracle') < 0);

const authenticated = computed(() => store.authenticated);
const adminAuthorities = computed(() => store.adminAuthority);
const readAuthorities = computed(() => accountService.readAuthorities);
Expand Down Expand Up @@ -62,6 +64,7 @@ export default defineComponent({
authenticated,
adminAuthorities,
readAuthorities,
h2Database,
};
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/app/core/jhi-navbar/jhi-navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<font-awesome-icon icon="book" />
<span>API</span>
</b-dropdown-item>
<b-dropdown-item v-if="!inProduction" href="./h2-console/" target="_tab">
<b-dropdown-item v-if="!inProduction && h2Database" href="./h2-console/" target="_tab">
<font-awesome-icon icon="database" />
<span>Database</span>
</b-dropdown-item>
Expand Down

0 comments on commit 6faf179

Please sign in to comment.