我对Spring Roo的2 M3工作项目。我意识到我需要一个新的发现者,除了我在引导项目时创建的发现者之外。 我生成在袋鼠控制台取景器:新的Finder不产生执行(M3)
finder add --entity ~.domain.Usuario --name findByUsername
它创建在java库
@RooFinder("findByUsername")
右注释和存储库中的方面
public abstract Page<Usuario> UsuarioRepository.findByUsername(String username, Pageable pageable);
的方法,但它没在服务中不会生成该查找程序,也不会像我以前生成的其他查找程序那样执行服务实现。
我GOOGLE了一段日子,并试图修复它我自己,但我没有取得进展。
请注意:这已经发生在我的其他春天roo 2 M3项目几个月前。我有同样的问题像一个星期,然后经过多次随机配备的代码篡改最后袋鼠控制台引发的变化,但我不能想通了,为什么它的工作。
编辑: 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:新增UsuarioRepository.java后推入
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);
}
嗨!你能否提供一个示例“log.roo”文件来尝试重现你的问题?问候, – jcgarcia
以及我不知道确切的条件来重现此错误。我遭受这个错误的两个项目之间唯一的相似之处在于,我试图在项目初始引导大量时间之后添加新的查找器。如果你愿意,我可以发布这个项目的完整log.roo。 – holyknight
如果您可以发布它以获取更多信息来重现问题,那将会很棒。无论如何...你是否尝试关闭并重新打开Spring Roo shell来检查新方法是否生成? Regards – jcgarcia