【发布时间】:2021-04-13 01:35:18
【问题描述】:
我正在从属性文件中读取我的 SQL 查询,并且我正在传递给 @Query(value=xyz) 但得到一致的错误“属性值必须是常量”。有没有可用的解决方案?
public class QueryUtils {
public static Properties properties;
static {
try {
FileReader reader = new FileReader("sql.properties");
properties = new Properties();
properties.load(reader);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static String findAllTags2 = properties.getProperty("ResourceTagRepository.find_all_tags");
}
我正在尝试在打击代码中使用它。
@Component
@Repository
public interface QueryRepo extends JpaRepository<XYZ, Long>, JpaSpecificationExecutor<XYZ> {
@Query(value = findAllTags2)
public List<ResourceTagMapping> findAllTags(@Param("list") Set<String> names);
}
【问题讨论】:
标签: java sql spring spring-boot hibernate