Skip to content

@PostConstruct runs before @Sql #13761

@ghost

Description

@RunWith(SpringRunner.class)
@Sql("classpath:/import_data.sql")
@TestPropertySource({"classpath:/application-test.properties"})
@SpringBootTest(classes = {TestConfiguration.class})
public class ATests {

  @Autowired
  MyBean myBean;

}

@Component
class MyBean {

  @PostConstruct
  public void init() {
    // here some db operations
  }

}

when I test it, it throws exception which tells me that there is not any table structure there, but in import_data.sql I do create the table and insert some data, if I do the db operations later, it will success

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions