:私のモデルとインターフェイスに問題がありますか? (Javaの春ブーツWebアプリケーション)私は簡潔にするため省略し、完全なディレクトリと言う走行時のエラーを(持っている
エラー名を持つBeanを作成する「idea_Service」ファイル に定義されている[... COM \ vincentsnow \ 不満依存性はコンストラクタパラメータ0を通して表現。 ネストされた例外は org.springframework.beans.factory.BeanCreationExceptionです:\ Idea_Service.class] brightideas \サービスエラー名を持つBeanを作成 「idea_Repository」:失敗したinitメソッド の呼び出し。ネストされた例外はjava.lang.IllegalArgumentExceptionである: 管理対象の種類:クラスjava.lang.Objectの
と別:
エラー名でBeanを作成する 'idea_Repository':INIT メソッドの呼び出しに失敗しました。私はどこでもこれらの小文字の名前を使用していないクラスjava.lang.Objectの
: ないマネージ型:ネストされた例外は、java.lang.IllegalArgumentExceptionがあります。私はこのメッセージを理解できません...コンパイルしようとしているのに何らかの理由でファイル名を変更しようとしていると思います。私のファイルではSTSによってエラーが検出されません。ここで彼らは、次のとおりです。
Idea_Service.java(サービス)
package com.vincentsnow.brightideas.services;
import java.util.List;
import org.springframework.stereotype.Service;
import com.vincentsnow.brightideas.models.Idea;
import com.vincentsnow.brightideas.models.User;
import com.vincentsnow.brightideas.repositories.Idea_Repository;
@Service
public class Idea_Service {
private Idea_Repository ideaRepository;
public Idea_Service(Idea_Repository ideaRepository){
this.ideaRepository = ideaRepository;
}
public List<Idea> allIdeas(){
return ideaRepository.findAllIdeas();
}
public void createUser(String idea, User posted_by){
ideaRepository.save(idea, posted_by);
}
public Idea oneIdea(Long id) {
return ideaRepository.getSingleIdeaWhereId(id);
}
public List<Idea> likesof(Long id){
return ideaRepository.getLikesOfIdea(id);
}
}
Idea.java(モデル)
package com.vincentsnow.brightideas.models;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.validation.constraints.Size;
import com.vincentsnow.brightideas.models.User;
@Entity
public class Idea {
@Id
@GeneratedValue
private Long id;
@Column
@Size(min=3, max=5000)
private String idea;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="idea_id")
private User posted_by;
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(
name = "likes",
joinColumns = @JoinColumn(name = "idea_id"),
inverseJoinColumns = @JoinColumn(name = "user_id")
)
private List<Idea> likes;
}
Idea_Repository.java(リポジトリ)
間違っている何package com.vincentsnow.brightideas.repositories;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import com.vincentsnow.brightideas.models.Idea;
import com.vincentsnow.brightideas.models.User;
@Repository
public interface Idea_Repository extends CrudRepository {
@Query("SELECT a FROM ideas a")
List<Idea> findAllIdeas();
@Query(value="INSERT INTO ideas (idea, posted_by) VALUES (?1, ?2, ?3, ?4)", nativeQuery=true)
Idea save(String idea, User posted_by);
@Query("SELECT a FROM ideas a WHERE id=?1")
Idea getSingleIdeaWhereId(Long id);
@Query(value="SELECT likes WHERE idea_id = ?1", nativeQuery=true)
List<Idea> getLikesOfIdea(Long id);
}
彼らと一緒に?このエラーは何を意味しますか? STSは何をしようとしていますか?
persistence.xmlファイルを表示してください – Rinat
Idea_Service.javaの下にIdea.javaを貼り付けたようです – vandale
ああ、そうです!編集されました、ありがとうございます。 –