java - Spring Boot without Model + MySQL -
i need make application without using models, because require make model every tables - isn't needed me.
we can go class execute queries directly or rest api.
has have idea achieving this?
as suggested in other answers, not require models
.
see spring boot documentation , can download simple working example
- you need have
application.properties
file properties below
spring.datasource.url=jdbc:mysql://localhost:3306/test spring.datasource.username=dbuser spring.datasource.password=dbpass spring.datasource.driver-class-name=com.mysql.jdbc.driver
add spring boot jdbc dependency in
pom.xml
<dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-jdbc</artifactid> </dependency>
you want inject
jdbctemplate
in controller class or other component scanned class,
private final jdbctemplate jdbctemplate; @autowired public mycontroller(jdbctemplate jdbctemplate) { this.jdbctemplate = jdbctemplate; }
in way can autowire jdbctemplate in spring bean.
Comments
Post a Comment