Я делаю Restapi в Java Spring (Gradle). При составлении кода и попробуйте его в почтальстве, он возвращается с 404. Я не знаю почему, и это очень раздражает. < /P>
package arma.Arma.RestController;
import arma.Arma.Service.UserService;
import arma.Arma.doman.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(value = "api/user")
public class UserRestController {
@Autowired
UserService userService;
@RequestMapping(value = "/all", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public List getAll() {
return userService.getAll();
}
}
< /code>
userservice < /p>
package arma.Arma.Service;
import arma.Arma.Repository.UserRepository;
import arma.Arma.doman.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class UserService {
@Autowired
UserRepository userRepository;
public List getAll() {
return userRepository.findAll();
}
}
< /code>
пользователь < /p>
package arma.Arma.doman;
import javax.persistence.*;
@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "user_id", nullable = false)
private Long id;
@Column(name = "username", nullable = false)
private String username;
@Column(name = "email", nullable = false)
private String email;
@Column(name = "password", nullable = false)
private String password;
@Column(name = "user_type", nullable = false)
private UserType type;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
< /code>
Я читаю тонны решений, и ни один из них не помог. Кроме того, это первый раз, когда появился, я настроил Tomcat, Java, MySQL и т. Д. Во многих машинах, и теперь я действительно беспомощен.
Подробнее здесь: https://stackoverflow.com/questions/500 ... 04-message