Angular 在fullstack中找不到模型实体名称

Angular 在fullstack中找不到模型实体名称,angular,spring-boot,Angular,Spring Boot,我正在为我的web应用程序angular+springboot使用fullstack,当 我通过本地调用angular service类中的userEntity 主机:8080在那个时候我得到错误userEntity找不到 src/app/service/http client.service.ts:12:32中出错-错误TS2304: 找不到名称“UserEntity” 12 return this.httpClient.get<UserEntity[]>('http://

我正在为我的web应用程序angular+springboot使用fullstack,当 我通过本地调用angular service类中的userEntity 主机:8080在那个时候我得到错误userEntity找不到

src/app/service/http client.service.ts:12:32中出错-错误TS2304: 找不到名称“UserEntity”

12     return this.httpClient.get<UserEntity[]>('http://localhost:8080/user/get');
UserController.java

package com.material.Controller;
导入java.util.List;
导入org.springframework.beans.factory.annotation.Autowired;
导入org.springframework.web.bind.annotation.CrossOrigin;
导入org.springframework.web.bind.annotation.GetMapping;
导入org.springframework.web.bind.annotation.RequestMapping;
导入org.springframework.web.bind.annotation.RestController;
导入com.material.Entity.UserEntity;
导入com.material.Repo.UserRepository;
@RestController
@交叉原点(原点=”http://localhost:4200")
@请求映射(path=“user”)
公共类用户控制器{
@自动连线
私有用户存储库userRepo;
@GetMapping(“/get”)
公共列表getUsers(){
返回userRepo.findAll();
}
}
http-client-service.ts

从'@angular/core'导入{Injectable};
从'@angular/common/http'导入{HttpClient};
@注射的({
providedIn:'根'
})
导出类HttpClientService{
构造函数(私有httpClient:httpClient){}
getUsers()
{
返回此.httpClient.get('http://localhost:8080/user/get');
}
}

您没有
UserEntity
类,您需要在
.ts
文件中将class
UserEntity
定义为

public class UserEntity{
    public id : number;
    public name: string;
    public password: string;
    //... remain property with UserEntity in java if having
}
package com.material.Controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.material.Entity.UserEntity;
import com.material.Repo.UserRepository;
@RestController
@CrossOrigin(origins= "http://localhost:4200")
@RequestMapping(path="user")
public class UserController {

    @Autowired
    private UserRepository userRepo;

    @GetMapping("/get")
    public List<UserEntity> getUsers(){
        return userRepo.findAll();

    }
}
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class HttpClientService {

  constructor(private httpClient:HttpClient) { }
  getUsers()
  {
    return this.httpClient.get<UserEntity[]>('http://localhost:8080/user/get');
  }
}
public class UserEntity{
    public id : number;
    public name: string;
    public password: string;
    //... remain property with UserEntity in java if having
}