java-8

SonarQube on Java8-project gives jacoco-Exception

删除回忆录丶 提交于 2020-01-02 00:43:46
问题 I just downloaded the latest version, SonarQube 4.3, then try build a java-8 project with: mvn clean install mvn sonar:sonar That gives me the Exception below. Googling, I got the impression this is an earlier issue that should have been fixed... ? http://sonarqube.15.x6.nabble.com/Sonar-analyze-Java-1-8-project-Failure-td5023663.html http://jira.codehaus.org/browse/SONARJAVA-482 Does SonarQube 4.3 support java-8? Or any clue, what is the problem? ---------------------------------------------

SonarQube on Java8-project gives jacoco-Exception

二次信任 提交于 2020-01-02 00:42:53
问题 I just downloaded the latest version, SonarQube 4.3, then try build a java-8 project with: mvn clean install mvn sonar:sonar That gives me the Exception below. Googling, I got the impression this is an earlier issue that should have been fixed... ? http://sonarqube.15.x6.nabble.com/Sonar-analyze-Java-1-8-project-Failure-td5023663.html http://jira.codehaus.org/browse/SONARJAVA-482 Does SonarQube 4.3 support java-8? Or any clue, what is the problem? ---------------------------------------------

Why do we have to cast the List returned by Collectors.toList() to List<Integer> even though the elements of the Stream are already mapped to Integer? [duplicate]

左心房为你撑大大i 提交于 2020-01-01 19:35:08
问题 This question already has answers here : What is a raw type and why shouldn't we use it? (15 answers) Why does the Streams API need a hint for generic type in this case? (1 answer) Why does javac complain about generics unrelated to the class' type arguments? [duplicate] (1 answer) Closed 2 years ago . I'm mapping a raw Stream to a Stream<Integer> and then collect the elements to a List<Integer> . Why do I have to cast the result of collect(Collectors.toList()) to List<Integer> if my mapper -

How to load and iterate through properties file in Spring Boot

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 19:30:54
问题 I've a properties file in which the values are comma separated. I'm able to get the values as Object as below. Could anyone please tell me how to separate the values and get it in String. .properties key-1 = value1,value11 key-2 = value2,value22 key-3 = value3,value33 key-4 = value4,value44 Code @PropertySource( value = "classpath:test1.properties", name = "test1" ) AbstractEnvironment ae = (AbstractEnvironment)env; org.springframework.core.env.PropertySource test1Source = ae

Date validation for Java 8 Time API in Spring

ぃ、小莉子 提交于 2020-01-01 19:27:25
问题 We all know the classic example of a date validation in the controller inside the initBinder method: @InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm"); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); } But what is the alternative to support the new Java 8 Time API , where we need to replace DateFormat to DateTimeFormatter ? What tools Spring Framework provides for this? Thanks. 回答1

SEVERE: Unable to process Jar entry [module-info.class] in Tomcat 7 && Java 8

天涯浪子 提交于 2020-01-01 19:16:30
问题 I deployed war files in tomcat 7 , java 8 && Eclipse Version: Luna Service Release 1 (4.4.1) While running it is showing following error. INFO: validateJarFile(D:\EclipseWorkspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\administration\WEB-INF\lib\javax.el-api-3.0.0.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class Oct 30, 2018 4:03:19 PM org.apache.catalina.startup.ContextConfig processAnnotationsJar SEVERE: Unable to

How to avoid negative time between time difference?

☆樱花仙子☆ 提交于 2020-01-01 19:16:13
问题 I'm developing an app in which I'm using Java8 Time. I'm facing an issue. Let's say Time A is 08:00 and Time B is 17:00, so the difference of between these two times will be 9h which in my case is correct, but if Time A is 18:00 and Time B is 02:00 it should be 8h, but in my case my program is returning -16. Kindly someone guide me how to solve this. My code: @Test public void testTime() { DateTimeFormatter format = DateTimeFormatter.ofPattern("HH:mm"); String s = "18:00"; String e = "02:00";

How do you invert Map<v1, Set<v2>> to Map<v2, Set<v1>> in Java with stream()

╄→гoц情女王★ 提交于 2020-01-01 19:11:58
问题 I have a Map object Map<t1, Set<t2>> , and I want to go into the set and turn t2 in the sets into the keys of the new map. The original key t1 will be the new value of the map. For example, given a map containing two entries {key1: [a, b, c], key2: [c, d]} The resulting map would be {a: [key1], b: [key1], c: [key1, key2], d: [key2]} [ ] denotes Set in the above examples. 回答1: Java 8: map.entrySet() .stream() .flatMap(e -> e.getValue() .stream() .map(v -> new SimpleEntry<>(v, e.getKey())))

How do you invert Map<v1, Set<v2>> to Map<v2, Set<v1>> in Java with stream()

人盡茶涼 提交于 2020-01-01 19:11:47
问题 I have a Map object Map<t1, Set<t2>> , and I want to go into the set and turn t2 in the sets into the keys of the new map. The original key t1 will be the new value of the map. For example, given a map containing two entries {key1: [a, b, c], key2: [c, d]} The resulting map would be {a: [key1], b: [key1], c: [key1, key2], d: [key2]} [ ] denotes Set in the above examples. 回答1: Java 8: map.entrySet() .stream() .flatMap(e -> e.getValue() .stream() .map(v -> new SimpleEntry<>(v, e.getKey())))

This method must return a result of type Specification<Employee> in Java 8

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-01 19:04:07
问题 How to return using if else using Lambda expression ? public static Specification<Employee> textInAllColumns(Object value) { if (value instanceof String) { return (root, query, builder) -> builder .or(root.getModel().getDeclaredSingularAttributes().stream() .filter(a -> { return a.getJavaType() .getSimpleName() .equalsIgnoreCase("String") ? true : false; }) .map(a -> builder.like(root.get(a.getName()), getString((String) value))) .toArray(Predicate[]::new)); } else if (value instanceof