ulisesbocchio / jasypt-spring-boot

Jasypt integration for Spring boot
MIT License
2.87k stars 514 forks source link

jasypt-spring-boot 3.0.5 doesn't work with spring boot 2.3.12.RELEASE #367

Closed renyp-veteran closed 1 year ago

renyp-veteran commented 1 year ago

I spent almost whole day on tring to find the reason through jasypt-spring-boot's 'tutorials' and issues

I also found the issue

https://github.com/ulisesbocchio/jasypt-spring-boot/issues/218

which looks like my problem, however, it doesn't fix my problem. Could I ask you for help ? please !

my pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.12.RELEASE</version>
    </parent>
    <groupId>xxx</groupId>
    <artifactId>xxx</artifactId>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.github.ulisesbocchio</groupId>
            <artifactId>jasypt-spring-boot-starter</artifactId>
            <version>3.0.5</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.github.ulisesbocchio</groupId>
                <artifactId>jasypt-maven-plugin</artifactId>
                <version>3.0.5</version>
            </plugin>
        </plugins>
    </build>
</project>

my config:

server:
  port: 9818 
spring:
  application:
    name: @project.artifactId@
  datasource:
    username: ENC(nrmZtkF7T0kjG/VodDvBw93Ct8EgjCA+)

jasypt:
  encryptor:
    algorithm: PBEWithMD5AndDES
    iv-generator-classname: org.jasypt.iv.NoIvGenerator
    password: 123456

and the log:

[kc-support-label] 23-07-11.19:00:55.337 [background-preinit] [TID: N/A] INFO  Version.<clinit>[21] - HV000001: Hibernate Validator 6.1.7.Final
[kc-support-label] 23-07-11.19:00:55.736 [main] [TID: N/A] INFO  EnableEncryptablePropertiesBeanFactoryPostProcessor.postProcessBeanFactory[44] - Post-processing PropertySource instances
[kc-support-label] 23-07-11.19:00:55.737 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[105] - Skipping PropertySource configurationProperties [class org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource
[kc-support-label] 23-07-11.19:00:55.738 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource bootstrap [org.springframework.core.env.MapPropertySource] to EncryptableMapPropertySourceWrapper
[kc-support-label] 23-07-11.19:00:55.739 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource systemProperties [org.springframework.core.env.PropertiesPropertySource] to EncryptableMapPropertySourceWrapper
[kc-support-label] 23-07-11.19:00:55.740 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource systemEnvironment [org.springframework.boot.env.SystemEnvironmentPropertySourceEnvironmentPostProcessor$OriginAwareSystemEnvironmentPropertySource] to EncryptableSystemEnvironmentPropertySourceWrapper
[kc-support-label] 23-07-11.19:00:55.740 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource random [org.springframework.boot.env.RandomValuePropertySource] to EncryptablePropertySourceWrapper
[kc-support-label] 23-07-11.19:00:55.740 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource springCloudClientHostInfo [org.springframework.core.env.MapPropertySource] to EncryptableMapPropertySourceWrapper
[kc-support-label] 23-07-11.19:00:55.801 [main] [TID: N/A] INFO  DefaultLazyPropertyFilter.lambda$new$2[45] - Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter
[kc-support-label] 23-07-11.19:00:55.808 [main] [TID: N/A] INFO  DefaultLazyPropertyResolver.lambda$new$2[46] - Property Resolver custom Bean not found with name 'encryptablePropertyResolver'. Initializing Default Property Resolver
[kc-support-label] 23-07-11.19:00:55.809 [main] [TID: N/A] INFO  DefaultLazyPropertyDetector.lambda$new$2[44] - Property Detector custom Bean not found with name 'encryptablePropertyDetector'. Initializing Default Property Detector

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::       (v2.3.12.RELEASE)

[kc-support-label] 23-07-11.19:00:57.569 [main] [TID: N/A] INFO  LabelApplication.logStartupProfileInfo[648] - No active profile set, falling back to default profiles: default
[kc-support-label] 23-07-11.19:00:58.616 [main] [TID: N/A] WARN  ClassPathMapperScanner.warn[44] - No MyBatis mapper was found in '[com.kcwl.label.*.infrastructure.repository.mapper]' package. Please check your configuration.
[kc-support-label] 23-07-11.19:00:58.706 [main] [TID: N/A] INFO  EnableEncryptablePropertiesBeanFactoryPostProcessor.postProcessBeanFactory[44] - Post-processing PropertySource instances
[kc-support-label] 23-07-11.19:00:58.706 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource ApolloBootstrapPropertySources [org.springframework.core.env.CompositePropertySource] to EncryptableEnumerablePropertySourceWrapper
[kc-support-label] 23-07-11.19:00:58.707 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource ApolloPropertySources [org.springframework.core.env.CompositePropertySource] to EncryptableEnumerablePropertySourceWrapper
[kc-support-label] 23-07-11.19:00:58.707 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[105] - Skipping PropertySource configurationProperties [class org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource
[kc-support-label] 23-07-11.19:00:58.707 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[105] - Skipping PropertySource servletConfigInitParams [class org.springframework.core.env.PropertySource$StubPropertySource
[kc-support-label] 23-07-11.19:00:58.707 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[105] - Skipping PropertySource servletContextInitParams [class org.springframework.core.env.PropertySource$StubPropertySource
[kc-support-label] 23-07-11.19:00:58.707 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource systemProperties [org.springframework.core.env.PropertiesPropertySource] to EncryptableMapPropertySourceWrapper
[kc-support-label] 23-07-11.19:00:58.707 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource systemEnvironment [org.springframework.boot.env.SystemEnvironmentPropertySourceEnvironmentPostProcessor$OriginAwareSystemEnvironmentPropertySource] to EncryptableSystemEnvironmentPropertySourceWrapper
[kc-support-label] 23-07-11.19:00:58.707 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource random [org.springframework.boot.env.RandomValuePropertySource] to EncryptablePropertySourceWrapper
[kc-support-label] 23-07-11.19:00:58.707 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource springCloudClientHostInfo [org.springframework.core.env.MapPropertySource] to EncryptableMapPropertySourceWrapper
[kc-support-label] 23-07-11.19:00:58.707 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource applicationConfig: [classpath:/application.yml] [org.springframework.boot.env.OriginTrackedMapPropertySource] to EncryptableMapPropertySourceWrapper
[kc-support-label] 23-07-11.19:00:58.707 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource springCloudDefaultProperties [org.springframework.core.env.MapPropertySource] to EncryptableMapPropertySourceWrapper
[kc-support-label] 23-07-11.19:00:58.708 [main] [TID: N/A] INFO  EncryptablePropertySourceConverter.makeEncryptable[110] - Converting PropertySource cachedrandom [org.springframework.cloud.util.random.CachedRandomPropertySource] to EncryptablePropertySourceWrapper
[kc-support-label] 23-07-11.19:00:58.982 [main] [TID: N/A] INFO  DefaultLazyPropertyFilter.lambda$new$2[45] - Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter
[kc-support-label] 23-07-11.19:00:58.988 [main] [TID: N/A] INFO  DefaultLazyPropertyResolver.lambda$new$2[46] - Property Resolver custom Bean not found with name 'encryptablePropertyResolver'. Initializing Default Property Resolver
[kc-support-label] 23-07-11.19:00:58.988 [main] [TID: N/A] INFO  DefaultLazyPropertyDetector.lambda$new$2[44] - Property Detector custom Bean not found with name 'encryptablePropertyDetector'. Initializing Default Property Detector
[kc-support-label] 23-07-11.19:00:59.250 [main] [TID: N/A] INFO  Http11NioProtocol.log[173] - Initializing ProtocolHandler ["http-nio-8009"]
[kc-support-label] 23-07-11.19:00:59.250 [main] [TID: N/A] INFO  StandardService.log[173] - Starting service [Tomcat]
[kc-support-label] 23-07-11.19:00:59.250 [main] [TID: N/A] INFO  StandardEngine.log[173] - Starting Servlet engine: [Apache Tomcat/9.0.46]
[kc-support-label] 23-07-11.19:00:59.381 [main] [TID: N/A] INFO  [/].log[173] - Initializing Spring embedded WebApplicationContext
[kc-support-label] 23-07-11.19:00:59.476 [main] [TID: N/A] DEBUG DecryptParamFilter.init[242] - Filter 'decryptParamFilter' configured for use
[kc-support-label] 23-07-11.19:00:59.476 [main] [TID: N/A] DEBUG ContentCacheFilter.init[242] - Filter 'contentCacheFilter' configured for use
[kc-support-label] 23-07-11.19:00:59.566 [main] [TID: N/A] INFO  TenantDataSource.addDataSource[45] - tenant-datasource - load a datasource named [label_MASTER_0] success
[kc-support-label] 23-07-11.19:00:59.566 [main] [TID: N/A] INFO  TenantDataSource.addDataSource[45] - tenant-datasource - load a datasource named [tidb_MASTER_0] success
[kc-support-label] 23-07-11.19:00:59.567 [main] [TID: N/A] INFO  TenantDataSource.addDataSource[45] - tenant-datasource - load a datasource named [tidb_SLAVE_0] success
[kc-support-label] 23-07-11.19:00:59.578 [main] [TID: N/A] INFO  DefaultLazyEncryptor.lambda$new$2[46] - String Encryptor custom Bean not found with name 'jasyptStringEncryptor'. Initializing Default String Encryptor
[kc-support-label] 23-07-11.19:00:59.589 [main] [TID: N/A] INFO  StringEncryptorBuilder.get[119] - Encryptor config not found for property jasypt.encryptor.key-obtention-iterations, using default value: 1000
[kc-support-label] 23-07-11.19:00:59.589 [main] [TID: N/A] INFO  StringEncryptorBuilder.get[119] - Encryptor config not found for property jasypt.encryptor.pool-size, using default value: 1
[kc-support-label] 23-07-11.19:00:59.589 [main] [TID: N/A] INFO  StringEncryptorBuilder.get[119] - Encryptor config not found for property jasypt.encryptor.provider-name, using default value: null
[kc-support-label] 23-07-11.19:00:59.590 [main] [TID: N/A] INFO  StringEncryptorBuilder.get[119] - Encryptor config not found for property jasypt.encryptor.provider-class-name, using default value: null
[kc-support-label] 23-07-11.19:00:59.590 [main] [TID: N/A] INFO  StringEncryptorBuilder.get[119] - Encryptor config not found for property jasypt.encryptor.salt-generator-classname, using default value: org.jasypt.salt.RandomSaltGenerator
[kc-support-label] 23-07-11.19:00:59.591 [main] [TID: N/A] INFO  StringEncryptorBuilder.get[119] - Encryptor config not found for property jasypt.encryptor.string-output-type, using default value: base64
[kc-support-label] 23-07-11.19:00:59.886 [main] [TID: N/A] WARN  AnnotationConfigServletWebServerApplicationContext.refresh[559] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'labelInfoDomainService': Unsatisfied dependency expressed through field 'labelInfoService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'labelInfoServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'labelInfoMapper' defined in file [F:\3-code\0-vSix-support-service\kc-support-label\target\classes\com\kcwl\label\infrastructure\repository\mapper\LabelInfoMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tenantDataSource' defined in class path resource [com/kcwl/framework/datasource/TenantDataSourceAutoConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Could not bind properties to 'DataSourceProperties' : prefix=spring.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.datasource.username' to java.lang.String
[kc-support-label] 23-07-11.19:00:59.887 [main] [TID: N/A] INFO  StandardService.log[173] - Stopping service [Tomcat]
[kc-support-label] 23-07-11.19:00:59.915 [main] [TID: N/A] ERROR LoggingFailureAnalysisReporter.report[40] - 

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'spring.datasource.username' to java.lang.String:

    Reason: Failed to bind properties under 'spring.datasource.username' to java.lang.String

Action:

Update your application's configuration

Disconnected from the target VM, address: '127.0.0.1:63408', transport: 'socket'

Process finished with exit code 1
renyp-veteran commented 1 year ago

Sorry, it's my carelessness, I found the online DES encrypt-tool to encrypt text, whick wasn't match with jasypt's default algorithm. Spring-Boot and Jasypt-Spring-Boot compatibility was fine.