0. Introduction
To deploy an application it is important to test this check-list:- There are no compilation errors in Eclipse
- The application runs
- The Maven pom.xml file has no errors
- There are no problems generating the "war" file
1. Compilation errors
I have made some java code that behaves in an odd mode. I have no compiler errors in Eclipse, but when I want to make execute Maven with the goals "clean package" and profile "production", I get compilation errors from Maven. Here are the errors:1.1 Incompatible types: int cannot be converted to java.lang.Short
This error is produced in this scenario:1. A function is declared as:
String MyFunction (Short counter) {..}
2. A call to this function:
String myString=MyFunction(1); // No compile errors in Eclipse
The solution consists of changing the parameter as follows.
String myString=MyFunction(Short.valueOf("1"));
1.2 Incompatible types: cannot infer type-variable(s) T,U,T,Q
[ERROR] (argument mismatch; java.util.Comparator<T> cannot be converted to java.util.Comparator<? super U>)
This error is produced in this scenario:1. A variable is declared as:
Comparator<Base> myComp;
2. Afunction is declared as:
public static <Q> Q getMtd(Base bean, String fldName) {..}
myComp=Comparator.comparing(
a -> getMtd(a, nm),
Comparator.reverseOrder()); // No compile errors in Eclipse
The solution consists of this strange typing
myComp=Comparator.comparing(
a -> getMtd(a, nm),
Comparator.<Base>reverseOrder());
No hay comentarios:
Publicar un comentario