Co jest przyczyną warningu "Request method 'POST' not supported"?

0

Koledzy co może byc przyczyna tego, że dostaje warning "Request method 'POST' not supported". Poniżej wrzucam klasy mojego projektu:

Model:

@Entity
public class User 
{

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;	
private String first_name;	
private String last_name;



public String getFirst_name() {
	return first_name;
}
public void setFirst_name(String first_name) {
	this.first_name = first_name;
}
public String getLast_name() {
	return last_name;
}
public void setLast_name(String last_name) {
	this.last_name = last_name;
}
public Long getId() {
	return id;
}
public void setId(Long id) {
	this.id = id;
}
public User() {

}
}
 

Controller:

 
@RestController
@RequestMapping("/user")
public class UserContoller 
{



private final UserRepository user_repository;



@Autowired
public UserContoller(UserRepository user_repository) {
	super();
	this.user_repository = user_repository;
}


@RequestMapping(method=RequestMethod.POST)
public User add_user(@RequestBody User user){
	
	user_repository.save(user);
	return user; 
}
	

@RequestMapping(method=RequestMethod.GET)
public List<User> get_all_user(){
	
	return user_repository.findAll();
}

}

Screen z warn:
screen1.PNG

screen2.PNG

0

A jesteś pewien że to przebudowałeś i uruchamiasz poprawna wersję? Możesz pokazać cały startup log na pastebinie?

0

Ok wyjaśnione, pomieszałem nazwy pakietów i dlatego nie działało ale mam pytanie :
Podawałem przy tworzeniu projektu nazwe pakietu. Jak powinna wygladać struktura mojego projektu. Poniżej dwa przypadki. Nazwa jaka podawałem przy tworzeniu projektu w Spring boot to glowny.pl i tam jest

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class MyErpApplication {

    public static void main(String[] args) {
        SpringApplication.run(MyErpApplication.class, args);
    }
}

przypadek1.PNG

przypadek2.PNG

1

Nie rozumiem pytania. To jest przecież ta sama struktura.

0

Racja to jest ta sama struktura. Wrzuciłem to do IDE i teraz widze jak to działa. Głupie pytanie. Zamykam temat ponieważ główny wątek został rozwiązany.

1 użytkowników online, w tym zalogowanych: 0, gości: 1