Spring Boot (1) Creating an application
1. Creating a project
1. Download IntelliJ or Eclipse
2. Use Initializr to create a gradle project. An example of creating an application is:
3. Import from IntelliJ
Extrat the zip file.
File -> New -> Project from existing sources and select the build.gradle file
The Project, editor and gradle windows are displayed.
If we try to run the application (Gradle window ->demo02 -> Tasks -> application -> bootRun) fails "application finished with non-zero exit value 1"
2- Review of web and REST concepts
URL concepts
REST API Methods
From testfully.io:
POST Creates a respource
PUT Updates enterely a resource
PATCH Updates partiall a resource
DELETE Deletes a resource
HEAD Similar to GET but has no BODY response
OPTIONS Gets information about communication options (permitted HTTP methods and CORS)
TRACE For diagnostics
CONNECT Makes a 2-way connection between client and the resource
3. src/main/resources/application.properties
From DZone we get this file
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect spring.jpa.hibernate.ddl-auto=none spring.jpa.hibernate.show-sql=true spring.datasource.url=jdbc:postgresql://localhost:5432/mydb spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.username=myUser spring.datasource.password=myPassword spring.datasource.initialization-mode=always spring.datasource.initialize=true spring.datasource.schema=classpath:/schema.sql spring.datasource.continue-on-error=true
Make sure you have created a Postgres DB and the properties are correct!
After saving this file the program runs! In the browser point to http://localhost/8080 and you get the WhiteLabel Error page.
Comentarios
Publicar un comentario