java - Spring Boot/Web with MySql database -
i have read various question, spring tutorials , looked @ different example projects, still not it. among others these: unable connect spring mysql http://www.codejava.net/frameworks/spring/spring-mvc-with-jdbctemplate-example
my goal gradle spring boot/web application connects mysql database.
my problem there many different ways configure project.
i use few xml possible.
so question is, whether possible achieve goal without having single xml file , if - how?
or if need xml file(it should pom.xml think). explanation why need , file in general.
please note: have 0 knowledge how configure spring, mysql, hibernate. things may straightforward you, unclear me. appreciate explanantions.
edit2:
i got sample application running using spring initializer
but, sample application uses maven - uses pom.xml:
<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>org.test</groupid> <artifactid>demo</artifactid> <version>0.0.1-snapshot</version> <packaging>jar</packaging> <name>demo</name> <description>demo project spring boot</description> <parent> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-parent</artifactid> <version>1.2.3.release</version> <relativepath/> <!-- lookup parent repository --> </parent> <properties> <project.build.sourceencoding>utf-8</project.build.sourceencoding> <start-class>demo.demoapplication</start-class> <java.version>1.7</java.version> </properties> <dependencies> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-data-jpa</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-jdbc</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-web</artifactid> </dependency> <dependency> <groupid>mysql</groupid> <artifactid>mysql-connector-java</artifactid> <scope>runtime</scope> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-test</artifactid> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-maven-plugin</artifactid> </plugin> </plugins> </build> </project>
is there eaasy way can replace code gradle or kind of tutorial tells me how replace code correct gradle file?
the simplest way may download "bootstrapped" project using spring initializr. can select dependencies require , build system, , generate project you.
for spring boot connect mysql instance, should sufficient have following properties in application.properties
file:
spring.datasource.url=jdbc:mysql://localhost:3306/db spring.datasource.username=user spring.datasource.password=password
see spring boot reference working sql databases more information.
Comments
Post a Comment