我使用logback库实现了一个spring boot项目的日志记录.我想根据我的spring配置文件(属性'spring.pofiles.active')加载不同的日志配置文件.我有3个文件:logback-dev.xml,logback-inte.xml和logback-prod.xml.我使用的是春季启动版本1.2.2.RELEASE.
正如您可以阅读spring boot文档(此处).它说:
可以通过在类路径中包含适当的库来激活各种日志记录系统,并通过在类路径的根目录中提供合适的配置文件或在Spring Environment属性logging.config指定的位置进一步自定义.(但请注意,由于在创建ApplicationContext之前初始化日志记录,因此无法在Spring @Configuration文件中控制@PropertySources的日志记录.系统属性和传统的Spring Boot外部配置文件工作正常.)
所以我尝试在application.properties文件中设置'logging.config'属性:
logging.config=classpath:/logback-${spring.profiles.active}.xml
Run Code Online (Sandbox Code Playgroud)
但是,当我启动我的应用程序时,我的logback- {profile} .xml未加载...
我认为日志记录是所有使用spring boot的项目遇到的常见问题.我想知道我是否在正确的方向,因为我有其他解决方案,但我觉得它们不优雅(在logback.xml文件或命令行属性中使用Janino进行条件解析).
我想使用 spring 库UriComponentsBuilder生成以下路径: '/app#/fragment1?test=toto'。
到目前为止我已经尝试过:
UriComponentsBuilder ucb = UriComponentsBuilder.fromPath("/app").fragment("fragment1").queryParam("test","toto");
ucb.toUriString(); // -> gives me as result : '/app?test=toto#/fragment1'
Run Code Online (Sandbox Code Playgroud)
知道如何以优雅的方式实现这一点吗?
我正在尝试在Spring应用程序中进行嵌套验证。
public class Parent{
public interface MyGroup{}
@NotNull(groups = MyGroup.class)
private Child child;
// getters and setters omited
}
public class Child{
public interface OptionalGroup {}
@NotBlank(groups = OptionalGroup.class)
private String aField;
}
Run Code Online (Sandbox Code Playgroud)
我已经从javax.validation包中查看了@Valid,但它不支持组。我还检查了spring的@Validated注解,但无法将其应用于字段。
我想做这样的事情:
public class Parent{
public interface MyGroup{}
@NotNull(groups = MyGroup.class)
@CascadeValidate(groups = MyGroup.class, cascadeGroups = OptionalGroup.class)
// 'groups' correspond to parent group and 'cascadeGroups' to a group that needs to be apply to the Child field.
private Child child;
}
Run Code Online (Sandbox Code Playgroud)
然后,我可以在任何想要的地方进行务实的操作:
@Inject SmartValidator validator;
public void …Run Code Online (Sandbox Code Playgroud) 我无法在我的select html bloc中检索所选选项(ng-model = filter)的实际值.
请注意,如果我没有设置$ scope.filter,那么即使我在下拉列表中选择了一个选项,$ scope.filter也会保持未定义状态.
我的html模板,filters.html:
<div ng-if="!showFilterTemplatePlz"> <button class="btn btn-primary" ng-click="showFilterTemplate()" type="button">Add Filter</button> </div> <div ng-if="showFilterTemplatePlz" class="inline"> <button class="btn btn-primary" ng-click="closeFilters()" type="button">Close filters</button> <label>filters</label> <select ng-model="filter" ng-options="filter.name for filter in filterOptions" class="form-control"> </select> <p>{{filter.name}}</p> <button ng-click="addFilter()" id="addFilterButton" class="btn btn-primary btn-sm btn-default" type="button"><i class="fa fa-plus"></i> Add</button> </div>
在我的指令中:
Run Code Online (Sandbox Code Playgroud).directive('filters', ['retrieveStaticDatasService','usersService', function(datasService, usersService) { return { restrict: 'E', scope: false, controller: function ($scope) { /* init */ $scope.filterOptions = [ {name: "languages"}, {name: "nationality"}, {name: "location"} ]; $scope.filter …
spring ×3
angularjs ×1
java ×1
logback ×1
logging ×1
nested ×1
query-string ×1
spring-boot ×1
url-encoding ×1
validation ×1