package com.org.Music_App.Artists;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import com.org.Music_App.Albums.Album;
@Entity
public class Artists {
@Id
private int artists_Id;
private String artists_Name;
private int no_of_Albums;
private String debut_Album;
@OneToMany
@JoinColumn(name = "artists_id")
@Transient
private List<Album> album;
public Artists() {
}
public Artists(int artists_Id, String artists_Name, int no_of_Albums, String debut_Album) {
this.artists_Id = artists_Id;
this.artists_Name = artists_Name;
this.no_of_Albums = no_of_Albums;
this.debut_Album = debut_Album;
}
public int getArtists_Id() {
return artists_Id;
}
public void setArtists_Id(int artists_Id) {
this.artists_Id = artists_Id;
}
public String getArtists_Name() {
return artists_Name;
}
public void setArtists_Name(String artists_Name) {
this.artists_Name = artists_Name;
}
public int getNo_of_Albums() {
return no_of_Albums;
}
public void setNo_of_Albums(int no_of_Albums) {
this.no_of_Albums = no_of_Albums;
}
public String getDebut_Album() {
return debut_Album;
}
public void setDebut_Album(String debut_Album) {
this.debut_Album = debut_Album;
}
public List<Album> getAlbum() {
return album;
}
public void setAlbum(List<Album> album) {
this.album = album;
}
}
package com.org.Music_App.Albums;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;
import com.org.Music_App.Artists.Artists;
@Entity
public class Album {
@Id
private int album_Id;
private int artists_Id;
private String album_Name;
private int no_of_Songs;
private String artists_Name;
public Album()
{
}
public Album(int album_Id, int artists_Id, String album_Name, int no_of_Songs, String artists_Name) {
super();
this.album_Id = album_Id;
this.artists_Id = artists_Id;
this.album_Name = album_Name;
this.no_of_Songs = no_of_Songs;
this.artists_Name = artists_Name;
}
public int getAlbum_Id() {
return album_Id;
}
public void setAlbum_Id(int album_Id) {
this.album_Id = album_Id;
}
public int getArtists_Id() {
return artists_Id;
}
public void setArtists_Id(int artists_Id) {
this.artists_Id = artists_Id;
}
public String getAlbum_Name() {
return album_Name;
}
public void setAlbum_Name(String album_Name) {
this.album_Name = album_Name;
}
public int getNo_of_Songs() {
return no_of_Songs;
}
public void setNo_of_Songs(int no_of_Songs) {
this.no_of_Songs = no_of_Songs;
}
public String getArtists_Name() {
return artists_Name;
}
public void setArtists_Name(String artists_Name) {
this.artists_Name = artists_Name;
}
}
自定义方法:
package com.org.Music_App.Repository;
import java.util.List;
import org.springframework.data.repository.CrudRepository;
import com.org.Music_App.Albums.Album;
import com.org.Music_App.Artists.Artists;
public interface AlbumRepository extends CrudRepository<Album, Integer> {
public List<Album> findByArtists_Id(Integer artists_id) ;
}
错误:
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property artists found for type Album!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:77) ~[spring-data-commons-1.13.6.RELEASE.jar:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'albumRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property artists found for type Album!
您可以重试相同的代码删除所有下划线吗?
Java命名约定使用camelcase和Spring假定约定,以便正确地连接东西。
如果你有
@Id
private int albumId;
public int getAlbumId;
public void setAlbumId(int albumId);
我有以下代码和结构。我得到以下错误,这是很长的错误消息。 创建名称为'departmentController'的bean时出错:通过字段'departmentService'表示的不满意的依赖项;嵌套异常org.springframework.beans.factory.不满意依赖异常: 实体类 存储库接口 服务等级 控制器类 主课 项目结构 完整错误堆栈跟踪:
错误:org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为“Issue TemplateServiceImpl”的bean时出错:通过字段“repo”表示的不满足的依赖关系;嵌套异常为org.springframework.beans.factory.noSuchBeanDefinitionException:没
当我试图进入主页时,我有以下错误 在我的UserController中,我有以下代码 我的用户服务 我的UserServiceImpl 我的假设 web.xml 我的servlet上下文 根上下文为空。 我不知道哪里是可能的错误原因,我试图找到不同的选项,但如果我使用DAO模式,我会收到相同的错误,所以我想知道哪个是问题来解决它。 该项目的配置使用xml,但我认为解决这种情况并不重要。 问候!
我是Spring和hibernate框架的新手,我已经给出了依赖项上的注释,但是我不知道为什么会出现这个错误。 创建名为“customerController”的bean时出错:通过字段“customerDAO”表示的未满足的依赖关系;嵌套的异常是org。springframework。豆。工厂未满足的依赖项异常:创建名为“customerDAOImpl”的bean时出错:未满足的依赖项通过字段“
以下是跟踪: org.springframework.beans.factory.未满足的DependencyException:创建名称为'testController'的bean时出错:通过字段'testDAO'表示的依赖项未满足;嵌套异常org.springframework.beans.factory.BeanCreationException:创建名称为'testDAO'的bean时出错
我是sping-mvc的新手。我试图找到使用sping-mvc、hiberNate、mysql和jsf开发测试项目的好教程。最后我创建了示例项目。 我的第一个问题是, 就是这个Spring-mvc结构 但不幸的是,上面显示的是错误。 应用程序上下文。xml 人脸配置。xml web.xml 个人类 PersonDAOImpl类 个人服务Impl类 ManagedBeanClass类 错误是, 请给