Spring 数据 - 在投影中使用 属性 值

Spring Data - Using property values in projections

我有 Spring 数据存储应用程序,我在其中创建了这样的投影

@Projection(name = "UserWithAvatar", types = { User.class })
public interface UserWithAvatar {
    String getName();
    String getEmail();

    @Value("${app.url}/pictures/#{target.imageId}")
    String getAvatar();
}

非工作部分是getAvatar,它生成一个url供查看图片。
然而,这个 ${app.url} 在投影内部不起作用。
我如何在其中添加这个 application.properties 值?

#{} 块中使用 @environment.getProperty('app.url')。它适用于 Spring Boot 2.3.0,我不确定旧版本。

示例:

@Value("#{target.pictureUrl ?: @environment.getProperty('app.url') + 'static/default-avatar.png'}")
String getAvatarUrl();