Reputation: 322
My Spring boot application using Spring boot 1.5.12 and Java 8 executes perfectly fine in my development environment, but when deploying to testing environment, I'm facing difficulties:
I start the application with : mvn spring-boot:run and the execution stops with an error:
java.lang.IllegalArgumentException: Name for parameter binding must not be null or empty! On JDKs < 8, you need to use @Param for named parameters, on JDK 8 or better, be sure to compile with -parameters.
I did some searches and understand that in order that my repositories methods work, like this one:
@RepositoryRestResource(collectionResourceRel = "users", path = "users")
public interface UserRepository extends JpaRepository<User, Long>, UserRepositoryCustom {
@Query("SELECT u FROM User u WHERE u.primaryEmail.emailAddress = :emailAddress "
+ "AND u.deleted = 0")
Optional<User> findByPrimaryEmailAddress(String emailAddress);
I need to compile with the "-parameters" option, because I don't put the @Param annotation on the paremeter "emailAddress".
It works in Eclipse since there is an option activated for the compiler, but when I use maven to compile the app outside of Eclipse, the option must be set.
My problem is that in Spring boot documentation, and since I'm using the default spring-boot-maven-plugin in my pom.xml
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
it should manage this compiler option automatically, and it seems it doesn't.
When I compare the spring-boot-starter-parent-1.5.12.RELEASE.pom and the pom of the latest version of spring boot on github, I cannot see on my 1.5.12 version the
<parameters>true</parameters>
Do you have any idea of how I can fix my issue?
I will try to replace the spring-boot-maven-plugin with maven-compiler-plugin with the "-parameters" compiler arg, but I would be more confident if I could use the default spring-boot-maven-plugin.
Thank you!
Upvotes: 2
Views: 1446
Reputation: 322
I think that the option "-parameters" in spring-boot-maven-plugin" has probably been added recently, and the documentation is not correct for Spring boot 1.5.12 (maybe it is for Spring boot 2.0.0)
I resolved the issue by configuring myself the maven compiler:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
Important: the "-parameters" arg must be set
Upvotes: 2
Reputation: 131
You need parameter for emailAddress, jpql cant understand what parameter is given.
Optional<User> findByPrimaryEmailAddress(@Param("emailAddress") String emailAddress);
Try with that!
Upvotes: 0