我對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