Migration Guide 5.5.1_Cloud Extension_ja - terasolunaorg/terasoluna-gfw GitHub Wiki

1.0.1から1.1.1への移行ガイド

.. only:: html

 .. contents:: 目次
    :depth: 2
    :local:

1.1.1での主な変更点

1.1.1での主な変更点は以下の通りです。

  • TERASOLUNA Server Framework for Java を 5.5.1へ更新
  • spring-cloud-dependenciesをGreenwich.RELEASEへ更新
  • 新規にJava SE 11のサポートを開始

TERASOLUNA Server Framework for Javaを5.5.1へ更新

1.1.1から、TERASOLUNA Server Framework for Javaを5.5.1へ更新しました。

Note

TERASOLUNA Server Framework for JavaのMigrating Guide (5.4.1 to 5.5.1)を参照してください。

spring-cloud-dependenciesをGreenwich.RELEASEへ更新

spring-cloud-dependenciesをGreenwich.RELEASEへ更新しました。

新規にJava SE 11のサポートを開始

サポート対象であるJava SE 8に加えて、新規にJava SE 11のサポートを開始しました。

Note

Java SE 8からJava SE 11に移行を行う場合は、GCの内部構造が異なるので性能テスト等によりリソースの消費量を確認し、チューニングしてください。

1.0.1から1.1.1への移行手順

移行手順は、以下の通りです。

Note

凡例

Required : 手順の適用は必須
Required by case : 手順の適用は条件付きで必須
Optional : 手順の適用を推奨 (必要に応じて手順の適用を実施)
- : 手順の適用は必要なし

[全般]

.. tabularcolumns:: |p{0.10\linewidth}|p{0.75\linewidth}|p{0.15\linewidth}|
ステップ 手順 Your Projects
依存ライブラリを更新 Required

[Spring Boot]

.. tabularcolumns:: |p{0.10\linewidth}|p{0.75\linewidth}|p{0.15\linewidth}|
ステップ 手順 Your Projects
クラスパスの修正 Required
SecurityAutoConfigurationクラスの除外対応 Required by case
WebMvcMetricsAutoConfigurationクラスの除外対応 Required by case
ManagementWebSecurityAutoConfigurationクラスの除外対応 Required by case
ActuatorのProduction-ready化に伴う修正 Required by case
XMLによるBean定義の上書きを許容する対応 Required

[Spring Cloud AWS]

.. tabularcolumns:: |p{0.10\linewidth}|p{0.75\linewidth}|p{0.15\linewidth}|
ステップ 手順 Your Projects
ResourcePatternResolverの定義方法変更に伴う修正 Required by case
CloudWatchMetricPropertiesの仕様変更に伴う修正 Required by case
ContextStackAutoConfigurationの仕様変更に伴う修正 Required by case

[Spring Data]

.. tabularcolumns:: |p{0.10\linewidth}|p{0.75\linewidth}|p{0.15\linewidth}|
ステップ 手順 Your Projects
spring-boot-starter-data-redisの依存ライブラリ変更に伴う修正 Required by case
Bean定義変更に伴う修正 Required by case
cacheNamesアノテーションの仕様変更に伴う修正 Required by case
CrudRepositoryの仕様変更に伴う修正 Required by case

[Spring Data DynamoDB]

.. tabularcolumns:: |p{0.10\linewidth}|p{0.75\linewidth}|p{0.15\linewidth}|
ステップ 手順 Your Projects
Spring Bootと互換性のあるversionに修正 Required by case

[Spring JMS]

.. tabularcolumns:: |p{0.10\linewidth}|p{0.75\linewidth}|p{0.15\linewidth}|
ステップ 手順 Your Projects
Amazon SQSがサポートするJMSのversionに合わせた修正 Required by case

[Apache Commons Codec]

.. tabularcolumns:: |p{0.10\linewidth}|p{0.75\linewidth}|p{0.15\linewidth}|
ステップ 手順 Your Projects
[CODEC-134]Apache Commons Codecの脆弱性解決のための修正 Required

[Step 1] 依存ライブラリを更新

[手順が必要なケース]

この手順の適用は必須です。

[修正方法]

親プロジェクトのpomファイルについて terasoluna-gfw-parentversion5.5.1.RELEASE に修正してください。

  • ($YOUR_MULTIPLE_PROJECT_ROOT/pom.xml)
<!-- omitted -->
<dependencyManagement>
    <dependency>
        <groupId>org.terasoluna.gfw</groupId>
        <artifactId>terasoluna-gfw-parent</artifactId>
        <version>5.5.1.RELEASE</version>                        <!-- ### 修正箇所 ### -->
        <relativePath />
    </dependency>
</dependencyManagement>
<!-- omitted -->

親プロジェクトのpomファイルについて spring-cloud-dependenciesversionGreenwich.RELEASE に修正してください。

  • ($YOUR_MULTIPLE_PROJECT_ROOT/pom.xml)
<!-- omitted -->
<dependencyManagement>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>Greenwich.RELEASE</version>                    <!-- ### 修正箇所 ### -->
        <type>pom</type>
        <scope>import</scope>
    </dependency>
</dependencyManagement>
<!-- omitted -->

[Step 2] クラスパスの修正

[手順が必要なケース]

この手順の適用は必須です。

[修正方法]

TERASOLUNA Server Framework (spring-boot-dependencies) の更新に伴い、 WebMvcAutoConfigurationSpringBootServletInitializer のクラスパスが変更となりました。 具体的には以下のように修正してください。

<!-- omitted -->

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;                    <!-- ### 修正箇所 ### -->
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;                     <!-- ### 修正箇所 ### -->
import org.springframework.context.annotation.ImportResource;

@ImportResource({ "classpath*:META-INF/spring/applicationContext.xml", "classpath*:META-INF/spring/spring-security.xml",
                  "classpath*:/META-INF/spring/spring-mvc.xml"})

@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class,
                                      JmxAutoConfiguration.class, WebMvcAutoConfiguration.class })

public class Bootstrap extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        setRegisterErrorPageFilter(false);
        return application.sources(Bootstrap.class);
    }
}
<!-- omitted -->

[Step 3] SecurityAutoConfigurationクラスの除外対応

[手順が必要なケース]

Spring Securityを利用する場合、この手順の適用は必須です。

[修正方法]

TERASOLUNA Server Framework (spring-boot-dependencies) の更新に伴い、 Spring SecurityのBean定義をXMLで正しく定義していても SecurityAutoConfiguration が有効となりBean定義エラーとなるバグが発生します。

本事象を回避するために以下のように SecurityAutoConfiguration をexcludeしてください。

<!-- omitted -->

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ImportResource;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;                    <!-- ### 修正箇所 ### -->

@ImportResource({ "classpath*:META-INF/spring/applicationContext.xml", "classpath*:META-INF/spring/spring-security.xml",
                  "classpath*:/META-INF/spring/spring-mvc.xml"})

@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class,
                                      JmxAutoConfiguration.class, WebMvcAutoConfiguration.class,
                                      SecurityAutoConfiguration.class })                    <!-- ### 修正箇所 ### -->

public class Bootstrap extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        setRegisterErrorPageFilter(false);
        return application.sources(Bootstrap.class);
    }
}
<!-- omitted -->

[Step 4] WebMvcMetricsAutoConfigurationクラスの除外対応

[手順が必要なケース]

ヘルスチェックを利用する場合、この手順の適用は必須です。

[修正方法]

TERASOLUNA Server Framework (spring-boot-dependencies) の更新に伴い、ヘルスチェックを利用している( Spring Boot Actuator が有効である)場合、 CharacterEncodingFilter よりも先に WebMvcMetricsFilter が適用されてしまい正しくエンコードできないバグが発生します。 本事象を回避するために以下のように WebMvcMetricsAutoConfiguration をexcludeしてください。

<!-- omitted -->

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ImportResource;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.metrics.web.servlet.WebMvcMetricsAutoConfiguration;                    <!-- ### 修正箇所 ### -->

@ImportResource({ "classpath*:META-INF/spring/applicationContext.xml", "classpath*:META-INF/spring/spring-security.xml",
                  "classpath*:/META-INF/spring/spring-mvc.xml"})

@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class,
                                      JmxAutoConfiguration.class, WebMvcAutoConfiguration.class,
                                      SecurityAutoConfiguration.class, WebMvcMetricsAutoConfiguration.class })                    <!-- ### 修正箇所 ### -->

public class Bootstrap extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        setRegisterErrorPageFilter(false);
        return application.sources(Bootstrap.class);
    }
}
<!-- omitted -->

[Step 5] ManagementWebSecurityAutoConfigurationクラスの除外対応

[手順が必要なケース]

Spring Securityを利用する場合、この手順の適用は必須です。

[修正方法]

TERASOLUNA Server Framework (spring-boot-dependencies) の更新に伴い、 Spring SecurityのBean定義をXMLで正しく定義していても ManagementWebSecurityAutoConfiguration が有効となりBean定義エラーとなるバグが発生します。 本事象を回避するために以下のように ManagementWebSecurityAutoConfiguration をexcludeしてください。

<!-- omitted -->

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ImportResource;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.metrics.web.servlet.WebMvcMetricsAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration;                    <!-- ### 修正箇所 ### -->

@ImportResource({ "classpath*:META-INF/spring/applicationContext.xml", "classpath*:META-INF/spring/spring-security.xml",
                  "classpath*:/META-INF/spring/spring-mvc.xml"})

@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class,
                                      JmxAutoConfiguration.class, WebMvcAutoConfiguration.class,
                                      SecurityAutoConfiguration.class, WebMvcMetricsAutoConfiguration.class,
                                      ManagementWebSecurityAutoConfiguration.class })                    <!-- ### 修正箇所 ### -->

public class Bootstrap extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        setRegisterErrorPageFilter(false);
        return application.sources(Bootstrap.class);
    }
}
<!-- omitted -->

[Step 6] ActuatorのProduction-ready化に伴う修正

[手順が必要なケース]

ヘルスチェックを利用する場合、この手順の適用は必須です。

[修正方法]

TERASOLUNA Server Framework (spring-boot-dependencies) の更新に伴い、Actuatorのプロパティ定義が変更となりました。 base-pathを変更する際は management.endpoints.web.base-path に設定してください。

  • ($YOUR_MULTIPLE_PROJECT_ROOT/projectName-web/src/main/resources/application.yml)
<!-- omitted -->
spring:
  application:
    name: xxx
management:
  endpoints:
    web:
      base-path: /management                    <!-- ### 修正箇所 ### -->
<!-- omitted -->

「Spring Boot Actuatorの処理結果ステータス」で詳細情報を取得するために management.endpoint.health.show-detailsALWAYS を設定してください。

  • ($YOUR_MULTIPLE_PROJECT_ROOT/projectName-web/src/main/resources/application.yml)
<!-- omitted -->
spring:
  application:
    name: xxx
management:
  endpoints:
    web:
      base-path: /management
  endpoint:
    health:
      show-details: ALWAYS                    <!-- ### 修正箇所 ### -->
<!-- omitted -->

[Step 7] XMLによるBean定義の上書きを許容する対応

[手順が必要なケース]

この手順の適用は必須です。

[修正方法]

TERASOLUNA Server Framework (spring-boot-dependencies) の更新に伴い、AutoConfigurationで自動生成されるBeanに対しXML等で定義したBeanで上書きを許容する設定が必要となりました。 これに伴い、 spring.main.allow-bean-definition-overriding=true の設定を追加してください。

  • ($YOUR_MULTIPLE_PROJECT_ROOT/projectName-web/src/main/resources/application.yml)
<!-- omitted -->
spring:
  main:
    allow-bean-definition-overriding: true                    <!-- ### 修正箇所 ### -->
<!-- omitted -->

[Step 8] ResourcePatternResolverの定義方法変更に伴う修正

[手順が必要なケース]

Spring Cloud AWSを使用したS3内のAntパターンによるオブジェクト検索を利用する場合、この手順の適用は必須です。

[修正方法]

spring-cloud-dependencies の更新に伴い、S3内のAntパターンによるオブジェクト検索を行う際の ResourcePatternResolver の定義方法が変更となりました。 以下のように resourcePatternResolver に対し PathMatchingSimpleStorageResourcePatternResolver でラップするよう修正してください。

<!-- omitted -->
private ResourcePatternResolver resourcePatternResolver;

@Inject                    <!-- ### 追加箇所ここから ### -->
public void setupResolver(ApplicationContext applicationContext, AmazonS3 amazonS3){
    this.resourcePatternResolver = new PathMatchingSimpleStorageResourcePatternResolver(amazonS3, applicationContext);
}                    <!-- ### 追加箇所ここまで ### -->

<!-- omitted -->
Resource[] result = resourcePatternResolver.getResources("s3://myBucket/*");
<!-- omitted -->

[Step 9] CloudWatchMetricPropertiesの仕様変更に伴う修正

[手順が必要なケース]

カスタムメトリクスの CloudWatchMetricProperties を利用する場合、この手順の適用は必須です。

[修正方法]

spring-cloud-dependencies の更新に伴い、カスタムメトリクスの実装例で利用していた CloudWatchMetricProperties について、クラスパスやクラス名、取得できるプロパティの変更が発生しています。 アプリケーションのプロパティを取得することでも同様処理が可能なことからオンライン版クラウド拡張では CloudWatchMetricProperties の利用を廃止しました。 これに伴い、カスタムメトリクスの実装例を以下のようにアプリケーションのプロパティから取得するよう修正しています。

<!-- omitted -->
@ConfigurationProperties(prefix = "custom.metric")
public class CloudWatchMetricSender implements InitializingBean {

    @Value("${cloud.aws.cloudwatch.region:}")
    String region;

    @Value("${spring.application.name:autoScalingGroupName}")
    String autoScalingGroupName;

    @Value("${cloud.aws.cloudwatch.namespace:}")                    <!-- ### 修正箇所 ### -->
    String namespace;

    private AmazonCloudWatch amazonCloudWatch;

    private String instanceId;

    <!-- omitted -->

    @Scheduled(fixedRate = 5000)
    public void sendCloudWatch() {

        <!-- omitted -->

        PutMetricDataRequest request = new PutMetricDataRequest()
                .withNamespace(namespace)                           <!-- ### 修正箇所 ### -->
                .withMetricData(
                        // Used
                        new MetricDatum().withDimensions(InstanceIdDimension,
                                AutoScalingGroupNameDimension).withMetricName(
                                "HeapMemory.Used").withUnit(
                                StandardUnit.Bytes.toString()).withValue(
        <!-- omitted -->

[Step 10] ContextStackAutoConfigurationの仕様変更に伴う修正

[手順が必要なケース]

ContextStackAutoConfiguration を利用する場合、この手順の適用は必須です。

[修正方法]

spring-cloud-dependencies の更新に伴い、 ContextStackAutoConfiguration に定義されているAWS CloudFormationのスタック名自動検出を無効化するための設定条件が変更となりました。 これに伴い、動作環境に関わらず cloud.aws.stack.auto=false の設定を追加してください。

  • ($YOUR_MULTIPLE_PROJECT_ROOT/projectName-web/src/main/resources/application.yml)
<!-- omitted -->
cloud:
  aws:
    stack:
      auto: false                    <!-- ### 修正箇所 ### -->
<!-- omitted -->

[Step 11] spring-boot-starter-data-redisの依存ライブラリ変更に伴う修正

[手順が必要なケース]

spring-boot-starter-data-redis を利用している場合、この手順の適用は必須です。

[修正方法]

TERASOLUNA Server Framework (spring-boot-dependencies) の更新に伴い、 セッション外部管理およびキャッシュの抽象化で定義する依存ライブラリが以下のように変更となります。

セッション外部管理を利用する場合は以下のように修正してください。

  • ($YOUR_MULTIPLE_PROJECT_ROOT/projectName-web/pom.xml)
<!-- omitted -->
<dependencies>
    <dependency>
        <groupId>org.springframework.session</groupId>
        <artifactId>spring-session-data-redis</artifactId>
    </dependency>
    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
    </dependency>
</dependencies>
<!-- omitted -->

キャッシュの抽象化を利用する場合は以下のように修正してください。(または上記と同様でも動作します。)

  • ($YOUR_MULTIPLE_PROJECT_ROOT/projectName-web/pom.xml)
<!-- omitted -->
<dependencies>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-redis</artifactId>
    </dependency>
    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
    </dependency>
</dependencies>
<!-- omitted -->

[Step 12] Bean定義変更に伴う修正

[手順が必要なケース]

キャッシュの抽象化を利用する場合、この手順の適用は必須です。

[修正方法]

TERASOLUNA Server Framework (spring-boot-dependencies) の更新に伴い、 Redisを使用したキャッシュマネージャのBean定義が変更となりました。 キャッシュマネージャを利用する際は以下のようにBean定義を修正してください。

  • ($YOUR_MULTIPLE_PROJECT_ROOT/projectName-web/src/main/resources/META-INF/spring/functionaltest-env.xml)
<!-- omitted -->
<bean id="cacheManager"
    class="org.springframework.data.redis.cache.RedisCacheManager"
    factory-method="create"
    c:connection-factory-ref="redisConnectionFactory"
    p:transaction-aware="true" />
<bean id="redisConnectionFactory"
    class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
    p:host-name="${spring.redis.host}" p:port="${spring.redis.port}" />
<!-- omitted -->

また、上記修正に伴いプロパティ(yml)に以下を追加してください。

  • ($YOUR_MULTIPLE_PROJECT_ROOT/projectName-web/src/main/resources/application.yml)
<!-- omitted -->
spring:
  redis:
    host: 【RedisのIP】
    port: 【Redisのポート】
<!-- omitted -->

[Step 13] キャッシュアノテーションのcacheNames属性の仕様変更に伴う修正

[手順が必要なケース]

キャッシュの抽象化を利用する場合、この手順の適用は必須です。

[修正方法]

TERASOLUNA Server Framework (spring-boot-dependencies) の更新に伴い、 @CacheConfigcacheNames 属性を利用した際のキャッシュデータにキープレフィックスが付与されるようになりました。 例えば、以下のように @CacheConfig@Cacheable を設定している場合、 キャッシュキーは members::member/【#customerNo】 となります。

// omitted...
@CacheConfig(cacheNames = "members")
public class MemberUpdateServiceImpl implements MemberUpdateService {
  @Transactional(readOnly = true)
  @Cacheable(key = "'member/' + #customerNo")
  public Member findMember(String customerNo) throws IOException {
    // omitted...
  }
  // omitted...
}

[Step 14] CrudRepositoryの仕様変更に伴う修正

[手順が必要なケース]

リポジトリクラスを CrudRepository のサブインタフェースとして実装する場合、この手順の適用は必須です。

[修正方法]

TERASOLUNA Server Framework の更新に伴い、 CrudRepositoryfindOne メソッドが findById に変更となりました。 この変更に伴い CrudRepository を継承しているクラスは以下のように修正する必要があります。

import org.socialsignin.spring.data.dynamodb.repository.EnableScan;
import org.springframework.data.repository.CrudRepository;
import com.example.xxx.domain.common.shard.model.ShardingAccount;

@EnableScan
public interface AccountShardKeyRepository extends CrudRepository<ShardingAccount, String> {
  @Override
  @Cacheable(key = "'shardid/' + #a0")
  Optional<ShardingAccount> findById(String id);                    <!-- ### 修正箇所 ### -->
  <!-- omitted -->
}

AccountShardKeyRepository の変更に伴い、エンティティクラス ShardingAccount を以下のように修正する必要があります。

// omitted...
@DynamoDBTable(tableName = "ShardAccount")
public class ShardingAccount implements Serializable {

  private static final long serialVersionUID = 1L;

  @DynamoDBHashKey(attributeName = "user_id")
  private String id;                    <!-- ### 修正箇所 ### -->
  // omitted...

findById メソッドの変更に伴い、インターフェース実装クラス AccountShardKeyRepository を以下のように修正する必要があります。

// omitted...
@CacheConfig(cacheNames = "shardids")
@EnableScan
public interface AccountShardKeyRepository
                                        extends
                                        CrudRepository<ShardingAccount, String> {
  @Override
  @Cacheable(key = "'shardid/' + #a0")
  Optional<ShardingAccount> findById(String id);                    <!-- ### 修正箇所 ### -->
}

AccountShardKeyRepository の変更に伴い、シャーディングインターセプタクラス AccountShardInterceptor を以下のように修正する必要があります。

// omitted...
public class AccountShardInterceptor implements MethodInterceptor, InitializingBean {

  // omitted...
  @Override
  public Object invoke(MethodInvocation invocation) throws Throwable {
    String beforeKey = dataSourceLookupKeyHolder.get();
    String dataSourceKey = null;
    String account = shardAccountHelper.getAccountValue(invocation);
    if (null != account) {
      Optional<ShardingAccount> shardingAccount = accountShardKeyRepository                    <!-- ### 修正箇所 ### -->
              .findById(acccount);
      if (shardingAccount != null) {
          dataSourceKey = shardingAccount.get().getDataSourceKey();                            <!-- ### 修正箇所 ### -->
      }
    }
    // omitted...

ShardingAccount の変更に伴い、サービスクラス MemberRegisterServiceImpl を以下のように修正する必要があります。

@Service
public class MemberRegisterServiceImpl implements MemberRegisterService {
  // omitted...
  @Inject
  private ShardKeyResolver shardKeyResolver;

  @Override
  @Transactional
  public Member register(Member member) {
    // omitted...
    int insertMemberCount = memberRepository.insert(member);
    ShardingAccount shardingAccount = new ShardingAccount();
    shardingAccount.setId(member.getCustomerNo());                    <!-- ### 修正箇所 ### -->
    shardingAccount.setDataSourceKey(shardKeyResolver.resolveShardKey(member.getCustomerNo()));
    accountShardKeyRepository.save(shardingAccount);
    return member;
  }
}

[Step 15] Spring Bootと互換性のあるversionに修正

[手順が必要なケース]

DynamoDBを利用する場合、この手順の適用は必須です。

[修正方法]

TERASOLUNA Server Framework (spring-boot-dependencies) の更新に伴い、 spring-data-dynamodbversion5.0.4 に変更する必要があります。

  • ($YOUR_MULTIPLE_PROJECT_ROOT/projectName-web/pom.xml)
<!-- omitted -->
<dependency>
    <groupId>com.github.derjust</groupId>
    <artifactId>spring-data-dynamodb</artifactId>
    <version>5.0.4</version>                    <!-- ### 修正箇所 ### -->
</dependency>
<!-- omitted -->

[Step 16] Amazon SQSがサポートするJMSのversionに合わせた修正

[手順が必要なケース]

Amazon SQSとSpring JMSを併用する場合、この手順の適用は必須です。

[修正方法]

TERASOLUNA Server Framework (spring-boot-dependencies) の更新に伴い、 spring-jmsversion5.1.4.RELEASE に更新されます。 しかし、オンライン版クラウド拡張で紹介しているAmazon SQSではJMS1.1までしかサポートしていないため、 spring-jmsversion4.3.21.RELEASE に、 amazon-sqs-java-messaging-libversion1.0.4 に指定する必要があります。

  • ($YOUR_MULTIPLE_PROJECT_ROOT/projectName-web/pom.xml)
<!-- omitted -->
<dependencies>
     <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-jms</artifactId>
         <version>4.3.21.RELEASE</version>                    <!-- ### 修正箇所 ### -->
     </dependency>
     <dependency>
         <groupId>com.amazonaws</groupId>
         <artifactId>amazon-sqs-java-messaging-lib</artifactId>
         <version>1.0.4</version>                             <!-- ### 修正箇所 ### -->
     </dependency>
 </dependencies>
<!-- omitted -->

[Step 17] [CODEC-134] Apache Commons Codecの脆弱性解決のための修正

[手順が必要なケース]

Apache Commons CodecのBase64を使用している場合、この手順の適用は必須です。

[修正方法] 脆弱性解決のため、``java.util.Base64``に変更となりました。以下のように修正する必要があります。

【修正前】

<!-- omitted -->
import org.apache.commons.codec.binary.Base64;
<!-- omitted -->
String base64policy = Base64.encodeBase64String(policyDocument.getBytes(StandardCharsets.UTF_8));
<!-- omitted -->

【修正後】

<!-- omitted -->
import java.util.Base64;
<!-- omitted -->
String base64policy = Base64.getEncoder().encodeToString(policyDocument.getBytes(StandardCharsets.UTF_8));
<!-- omitted -->
⚠️ **GitHub.com Fallback** ⚠️