0
SpringブートWebアプリケーションでは、java.lang.IllegalStateException: getOutputStream()
がこの応答にすでに呼び出されています。SpringブートWebアプリケーション:throwing java.lang.IllegalStateException:この応答にgetOutputStream()が既に呼び出されています。
は、私は私のクラスにアクセスしようとすると
@Entity
public class Book {
@Id
@GeneratedValue
private Long id;
private String isbn;
private String title;
private String description;
@ManyToOne
private Author author;
@ManyToOne
private Publisher publisher;
@ManyToMany
private List<Reviewer> reviewers;
protected Book() {
}
public Book(String isbn, String title, Author author, Publisher publisher) {
this.isbn = isbn;
this.title = title;
this.author = author;
this.publisher = publisher;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getIsbn() {
return isbn;
}
public void setIsbn(String isbn) {
this.isbn = isbn;
}
public String getTitle() {
return title;
}
}
とテストクラス
public class StartupRunner implements CommandLineRunner {
protected final Log logger = LogFactory.getLog(getClass());
@Autowired
private BookRepository bookRepository;
@Autowired
private AuthorRepository authorRepository;
@Autowired
private PublisherRepository publisherRepository;
@Override
public void run(String... args) throws Exception {
logger.info("Number of books: " + bookRepository.count());
Author author = new Author("Alex", "Antonov");
author = authorRepository.save(author);
Publisher publisher = new Publisher("Packt");
publisher = publisherRepository.save(publisher);
Book book = new Book("978-1-78528-415-1", "Spring Boot Recipes", author, publisher);
bookRepository.save(book);
}
@Scheduled(initialDelay = 1000, fixedRate = 10000)
public void run() {
logger.info("Number of books: " + bookRepository.count());
}
}
メインクラス
public class StartupRunner implements CommandLineRunner {
protected final Log logger = LogFactory.getLog(getClass());
@Autowired
private BookRepository bookRepository;
@Autowired
private AuthorRepository authorRepository;
@Autowired
private PublisherRepository publisherRepository;
@Override
public void run(String... args) throws Exception {
logger.info("Number of books: " + bookRepository.count());
Author author = new Author("Alex", "Antonov");
author = authorRepository.save(author);
Publisher publisher = new Publisher("Packt");
publisher = publisherRepository.save(publisher);
Book book = new Book("978-1-78528-415-1", "Spring Boot Recipes", author, publisher);
bookRepository.save(book);
}
@Scheduled(initialDelay = 1000, fixedRate = 10000)
public void run() {
logger.info("Number of books: " + bookRepository.count());
}
}
のように見える@ManyToOne, @ManyToMany,
のORMの関係でメモリデータベースh2
を持っていますデータhttp://localhost:8080/books/978-1-78528-415-1 例外をスローする
私も同様の例外が発生しています。この問題を解決できましたか? – skumar