Skip to content

Commit

Permalink
fix review problem
Browse files Browse the repository at this point in the history
  • Loading branch information
shoothzj committed May 6, 2023
1 parent 7f24ac5 commit e05aaa4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
Expand All @@ -37,7 +38,6 @@

import javax.annotation.PostConstruct;
import javax.sql.DataSource;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;

Expand Down Expand Up @@ -66,7 +66,7 @@ public BizDBPropertySource(final ServerConfigRepository serverConfigRepository,

@PostConstruct
public void runSqlScript() throws Exception {
if (Arrays.asList(env.getActiveProfiles()).contains("h2")) {
if (env.acceptsProfiles(Profiles.of("h2"))) {
Resource resource = new ClassPathResource("jpa/init.h2.sql");
if (resource.exists()) {
DatabasePopulatorUtils.execute(new ResourceDatabasePopulator(resource), dataSource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.core.env.Profiles;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.jdbc.datasource.init.DatabasePopulatorUtils;
Expand All @@ -34,7 +35,6 @@

import javax.annotation.PostConstruct;
import javax.sql.DataSource;
import java.util.Arrays;
import java.util.Objects;


Expand Down Expand Up @@ -62,7 +62,7 @@ public PortalDBPropertySource(final ServerConfigRepository serverConfigRepositor

@PostConstruct
public void runSqlScript() throws Exception {
if (Arrays.asList(env.getActiveProfiles()).contains("h2")) {
if (env.acceptsProfiles(Profiles.of("h2"))) {
Resource resource = new ClassPathResource("jpa/init.h2.sql");
if (resource.exists()) {
DatabasePopulatorUtils.execute(new ResourceDatabasePopulator(resource), dataSource);
Expand Down

0 comments on commit e05aaa4

Please sign in to comment.