Spring Boot REST:忽略排序方向,但排序通常有效

由于还没有公认的答案,我发布了我的完整解决方案,它建立在@nationquest 的答案之上:


private ConfigClass loadConfiguration(String path){

    MutablePropertySources sources = new MutablePropertySources();

    Resource res = new FileSystemResource(path);

    PropertiesFactoryBean propFactory = new PropertiesFactoryBean();

    propFactory.setLocation(res);

    propFactory.setSingleton(false);


    // resolve potential references to local environment variables

    Properties properties = null;

    try {

        properties = propFactory.getObject();

        for(String p : properties.stringPropertyNames()){

            properties.setProperty(p, env.resolvePlaceholders(properties.getProperty(p)));

        }

    } catch (IOException e) {

        e.printStackTrace();

    }


    sources.addLast(new PropertiesPropertySource("prefix", properties));

    ConfigurationPropertySource propertySource = new MapConfigurationPropertySource(properties);

    return new Binder(propertySource).bind("prefix", ConfigClass.class).get();

}

最后三行是这里的相关部分。


绝地无双
浏览 139回答 1
1回答

蝴蝶刀刀

试试这个网址。http://localhost:8080/dimensionAttributeValues/search/findDimensionAttributeValueByDimensionAttributeDimensionAttributeID?dimensionAttributeId=1&page=0&size=1&sort=chrValue,desc.这将按降序对您的数据进行排序。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java