I have a working project on Spring Roo 2 M3. I realized that i needed a new finder apart from the ones that i created when i was bootstraping the project. I generated the finder in the roo console:
finder add --entity ~.domain.Usuario --name findByUsername
It created the right annotation in the java repository
@RooFinder("findByUsername")
and the method in the repository aspect
public abstract Page<Usuario> UsuarioRepository.findByUsername(String username, Pageable pageable);
but it didn't generate that finder in the service neither the service implementation like the other finders that i previously generated.
I googled it for some days and tried to fix it my self but i made no progress.
note: this already happened to me on other spring roo 2 M3 project some months ago. I had the same problem for like a week and then after many random tampering with the code finally the roo console triggered the changes but i couldn't figured out why it worked.
EDIT: log.roo
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-06 18:32:01
project setup --topLevelPackage ar.edu.um.ingsoftware --projectName "umbook"
jpa setup --database MYSQL --provider HIBERNATE --hostName 127.0.0.1 --databaseName umbook --userName root
entity jpa --class ~.reference.Persona --abstract
field string --fieldName username --notNull
field string --fieldName password --notNull
entity jpa --class ~.domain.Usuario --extends ~.reference.Persona
field string --fieldName email --notNull
field string --fieldName nombre --notNull
field string --fieldName apellido --notNull
field date --fieldName fechaNacimiento --type java.util.Calendar --past
entity jpa --class ~.domain.Administrador --extends ~.reference.Persona
entity jpa --class ~.domain.Comentario
field string --fieldName contenido --notNull
field reference --fieldName autor --type ~.domain.Usuario
field date --fieldName timestmp --type java.util.Calendar
repository jpa --all
finder add --name findByEmailEquals --entity ~.domain.Usuario
finder add --name findByNombreLike --entity ~.domain.Usuario
finder add --name findByApellidoLike --entity ~.domain.Usuario
service --all
web mvc setup
web mvc view setup --type THYMELEAF
web mvc controller --all --responseType THYMELEAF
// script --file script_roo
exit
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-06 18:32:26
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-06 18:57:39
web mvc finder --all --responseType THYMELEAF --pathPrefix 'find'
web mvc language --code es --useAsDefault
web mvc templates setup --type THYMELEAF
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-06 19:23:08
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-06 19:23:31
focus --class ~.domain.Usuario
field list --fieldName comentarios --type ~.domain.Comentario --mappedBy listaDeComentarios --cardinality ONE_TO_MANY
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-06 19:41:26
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-06 19:41:37
exit
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-06 19:42:18
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-06 19:42:36
focus --class ~.domain.Comentario
focus --class ~.domain.Usuario
// [failed] field list --fieldName comentariosHechos --type ~.domain.Comentario --mappedBy autor --cardinality ONE_TO_MANY
// [failed] field list --fieldName comentarios --type ~.domain.Comentario
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-06 19:53:59
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-06 19:54:16
focus --class ~.domain.Usuario
field list --fieldName comentarios --type ~.domain.Comentario
focus --class ~.domain.Comentario
focus --class ~.domain.Usuario
field list --fieldName comentarios --type ~.domain.Comentario --cardinality MANY_TO_MANY
field list --fieldName comentarios --type ~.domain.Comentario
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-06 19:58:35
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-06 19:58:50
// [failed] field list --fieldName comentariosHechos --type ~.domain.Comentario --mappedBy autor
focus --class ~.domain.Usuario
field list --fieldName comentariosHechos --type ~.domain.Comentario --mappedBy autor
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-06 23:36:33
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-16 18:03:39
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-19 04:51:01
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-24 20:40:34
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-24 20:42:02
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-24 20:42:15
help
project scan now
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-25 00:49:54
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-25 00:50:07
project scan status
project scan now
finder add --entity ~.domain.Usuario --name findByUsername
project scan now
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-26 04:59:57
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-26 05:00:09
project scan now
project scan now
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-26 05:12:02
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-26 05:12:13
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-26 05:15:11
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-26 05:16:30
project scan status
project scan status
project scan now
help
metadata status
help
version
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-26 05:36:24
// Spring Roo 2.0.0.M3 [rev 20a0f71] log opened at 2017-02-26 19:59:43
// Spring Roo 2.0.0.M3 [rev 20a0f71] log closed at 2017-02-26 20:59:20
EDIT2: Added UsuarioRepository.java after the push-in
package ar.edu.um.ingsoftware.repository;
import ar.edu.um.ingsoftware.domain.Usuario;
import org.springframework.roo.addon.layers.repository.jpa.annotations.RooJpaRepository;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.roo.addon.layers.repository.jpa.annotations.RooFinder;
@Transactional(readOnly = true)
/**
* = UsuarioRepository
*
* TODO Auto-generated class documentation
*
*/
@RooJpaRepository(entity = Usuario.class, finders = { @RooFinder("findByEmailEquals"), @RooFinder("findByNombreLike"), @RooFinder("findByApellidoLike"), @RooFinder("findByUsername") })
public interface UsuarioRepository extends JpaRepository<Usuario, Long>, UsuarioRepositoryCustom {
/**
* TODO Auto-generated method documentation
*
* @param email
* @param pageable
* @return Page
*/
public abstract Page<Usuario> findByEmailEquals(String email, Pageable pageable);
/**
* TODO Auto-generated method documentation
*
* @param email
* @return Long
*/
public abstract long countByEmailEquals(String email);
/**
* TODO Auto-generated method documentation
*
* @param nombre
* @param pageable
* @return Page
*/
public abstract Page<Usuario> findByNombreLike(String nombre, Pageable pageable);
/**
* TODO Auto-generated method documentation
*
* @param nombre
* @return Long
*/
public abstract long countByNombreLike(String nombre);
/**
* TODO Auto-generated method documentation
*
* @param apellido
* @param pageable
* @return Page
*/
public abstract Page<Usuario> findByApellidoLike(String apellido, Pageable pageable);
/**
* TODO Auto-generated method documentation
*
* @param apellido
* @return Long
*/
public abstract long countByApellidoLike(String apellido);
/**
* TODO Auto-generated method documentation
*
* @param username
* @param pageable
* @return Page
*/
public abstract Page<Usuario> findByUsername(String username, Pageable pageable);
/**
* TODO Auto-generated method documentation
*
* @param username
* @return Long
*/
public abstract long countByUsername(String username);
}
After analyze your issue, seems like some problem with the Spring Roo 2.0.0.M3 metadata listeners affects to the service generation when a new finder is included.
This problem has been fixed in Spring Roo 2.0.0.RC1 and it will be published really soon.
Anyway, if you make push-in
of the findByUsername
method, the service interface and the service implementation must include it.
Let me know if you have any problem with that!
Hope it helps,