@Entity
@Table(name = "Users")
public class User {
@Id
private String login;
private String phone;
//ссылка на фото
private String photo;
@ManyToMany
@JoinTable(name = "USER_Advertisement",
joinColumns = { @JoinColumn(name = "login") },
inverseJoinColumns = { @JoinColumn(name = "id") })
private Set<Advertisement> cart = new HashSet<>();
public User( String login, String phone, String photo) {
this.login = login;
this.phone = phone;
this.photo = photo;
}
@OneToMany
private Set<Advertisement> advertisements = new HashSet<>();
}
<spoiler title="репозиторий:"><code>
@Repository
public interface UserRepository extends CrudRepository<User, String> {
//сохранить клиента
User save(User user);
...
}
</code></spoiler>
<spoiler title="пытаюсь совершить:"><code>
@SpringBootApplication
public class NedoAvitoApplication implements ApplicationRunner {
@Autowired
UserRepository rec;
public static void main(String[] args) {
SpringApplication.run(NedoAvitoApplication.class, args);
}
@Override
public void run(ApplicationArguments args) throws Exception {
User a=new User("k", "ko", "gggggu");
rec.save(a);
}
}
</code></spoiler>
Но на строке rec.save(a): Caused by: org.postgresql.util.PSQLException: ERROR: relation "users" does not exist
<spoiler title="в настройках стоит автоматом создавать таблицы:"><code>
spring.datasource.url= jdbc:postgresql://localhost:5432/mydate
spring.datasource.username=test_user
spring.datasource.password=ххх
spring.datasource.driverClassName=org.postgresql.Driver
logging.level.org.hibernate=DEBUG
spring.jpa.hibernate.ddl-auto=create
spring.jpa.properties.hibernate.show_sql=true
spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=target/my-schema.sql
spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
javax.persistence.schema-generation.scripts.action=create
</code></spoiler>