小编Dea*_*ean的帖子

@Autowired 的配置属性在 Spring Boot 中为 null

我有一个属性类

@ConfigurationProperties(prefix = ShiroProperties.SHIRO_PREFIX)
public class ShiroProperties {
  public static final String SHIRO_PREFIX = "shiro";

  private String urlLogin;
  private String urlSuccessed;
Run Code Online (Sandbox Code Playgroud)

和一个配置类

@Configuration
@EnableConfigurationProperties({ ShiroProperties.class })
public class ShiroConfig implements ApplicationContextAware {

  ApplicationContext applicationContext;
  @Autowired
  private ShiroProperties shiroProperties ;
Run Code Online (Sandbox Code Playgroud)

shiroProperties 为空,但我可以在使用的 ShiroConfig 中找到它的值

applicationContext.getBean(ShiroProperties.class)
Run Code Online (Sandbox Code Playgroud)

我的应用程序类:

@SpringBootApplication
public class Bootstrap {
  public static void main(String[] args) {
    SpringApplication.run(Bootstrap.class, args);
  }
}
Run Code Online (Sandbox Code Playgroud)

太奇怪了,我可以在其他项目中使用类似的代码成功运行,但是这个。

java spring spring-boot

7
推荐指数
1
解决办法
1万
查看次数

在 kotlin 问题中,ByteArray 使用 UTF-8 字符集转换为字符串

我有点困惑

// default charset utf8
val bytes = byteArrayOf(78, 23, 41, 51, -32, 42)
val str = String(bytes)
// there i got array [78, 23, 41, 51, -17, -65, -67, 42]
val weird = str.toByteArray()
Run Code Online (Sandbox Code Playgroud)

由于某种原因,我将随机值放入字节属性中。为什么不一致???

string byte utf-8 kotlin

1
推荐指数
1
解决办法
372
查看次数

标签 统计

byte ×1

java ×1

kotlin ×1

spring ×1

spring-boot ×1

string ×1

utf-8 ×1