从gradle 5.x升级到7.x后,生成两个war文件。
下面是2个war文件名
test-app-1.0.0.war
test-app-1.0.0-plain.war
Run Code Online (Sandbox Code Playgroud)
下面是使用的 gradle 插件和任务:
plugins {
id 'war'
}
bootWar {
launchScript()
manifest {
attributes 'Implementation-Version': archiveVersion
}
}
Run Code Online (Sandbox Code Playgroud)
我只想生成test-app-1.0.0.war. 如何解决这个问题?
我有下面的代码并基于布尔值进行 groupingBy
Map<Boolean, List<Test>> products = testList
.stream()
.collect(Collectors.groupingBy(Test::isValidUser));
Run Code Online (Sandbox Code Playgroud)
我想把它收集起来Map<String, List<Test> 。
基于布尔值,想要将自定义键添加为“有效”和“无效”。
如果为isValidUsertrue,则要将密钥添加为“有效”,否则密钥应为“无效”
在 Java 11 中是否有可能做到这一点?
注意:没有在Test类中添加String变量
I want to find the month is equal or after the current YearMonth
final YearMonth yearMonth = YearMonth.of(2020, 8);
final boolean after = yearMonth.isAfter(YearMonth.now());
Run Code Online (Sandbox Code Playgroud)
Here current month is August(8) and I tried isAfter which returns false.
I want to return true for current month also.
Is any method is there in YearMonth itself?
我有以下字符串
String money = "USD0.00"
Run Code Online (Sandbox Code Playgroud)
想把这个转换成 org.joda.money.Money
我是否需要在此处拆分货币单位和双倍值,并需要在 Money. 或者有任何库 api 可以转换它吗?
迁移到 gradle 7.x 时出现以下错误
* What went wrong:
An exception occurred applying plugin request [id: 'no.nils.wsdl2java', version: '0.12']
> Failed to apply plugin 'no.nils.wsdl2java'.
> Configuration with name 'compile' not found.
Run Code Online (Sandbox Code Playgroud)
下面是在build.gradle中添加的wsdl2java
plugins {
id("no.nils.wsdl2java") version "0.12"
`java-library`
}
buildscript {
dependencies {
classpath("no.nils:wsdl2java:0.12")
}
}
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题?
我想从 Java 8+ 中的 Map<String,Integer> 收集最大数字列表的关联键
例如:
final Map<String, Integer> map = new HashMap<>();
map.put("first", 50);
map.put("second", 10);
map.put("third", 50);
Run Code Online (Sandbox Code Playgroud)
在这里我想返回与最大值关联的键列表。
对于上面的例子,预期输出是[first,third]。因为这两个键具有相同的最大值。
我尝试使用以下方法,但只能获得单个最大密钥。
final String maxKey = map.entrySet()
.stream()
.max(Map.Entry.comparingByValue())
.map(Map.Entry::getKey)
.orElse(null);
final List<String> keysInDescending = map.entrySet()
.stream()
.sorted(Map.Entry.<String,Integer>comparingByValue().reversed())
.map(Map.Entry::getKey)
.collect(Collectors.toList());
System.out.println(maxKey); // third
System.out.println(keysInDescending); //[third, first, second]
Run Code Online (Sandbox Code Playgroud)
但我的预期输出是[第一,第三]。在Java 8+版本中如何实现呢?
我有以下 api
@GetMapping(value = "/employees")
public List<Employee> getEmployees(
@RequestParam(value = "mode", required = false) final EmployeeMode mode) {
//calling service from here
}
Run Code Online (Sandbox Code Playgroud)
我将 EmployeeMode 枚举作为 requestParam。
public enum EmployeeMode {
REGULAR,
ALL,
TEMPROARY
}
Run Code Online (Sandbox Code Playgroud)
我想接受不区分大小写的请求。尝试使用@JsonAlias、@JsonCreator和objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);。spring.jackson.mapper.accept-case-insensitive-enums: true对我来说没有任何作用。
我正在使用 Spring Boot 2.5.5。
如何使用 requestParam 接受不区分大小写的请求?如果 requestParam 为空/null,则需要将默认枚举设置为 ALL。
想要从当前日期获取该月的第一天。
为了得到我正在做的 org.apache.commons.lang3.time.DateUtils 以以下格式返回
DateUtils.truncate(new Date(), 2);
Run Code Online (Sandbox Code Playgroud)
这将返回预期输出,如下所示:
Fri Jul 01 00:00:00 IST 2022
Run Code Online (Sandbox Code Playgroud)
还有其他方法可以使用与上述相同的日期时间格式获取当月的第一天吗?
java ×7
collections ×2
date ×2
datetime ×2
gradle ×2
java-8 ×2
java-stream ×2
spring-boot ×2
build.gradle ×1
collectors ×1
enums ×1
jackson ×1
joda-money ×1
spring ×1
war ×1