Skip to content

Commit

Permalink
Cambios para poder trabajar con JSPs
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbh committed Feb 26, 2021
1 parent f40a812 commit 757e5f2
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>

</dependencies>

<build>
Expand Down
46 changes: 46 additions & 0 deletions src/main/java/org/tecnificados/boot/WebSecurityConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
*
*/
package org.tecnificados.boot;






import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;


/**
* @author Juan Carlos Ballesteros (tecnificados.com)
*
*/

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/login").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
*
*/
package org.tecnificados.boot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
* @author Juan Carlos Ballesteros (tecnificados.com)
*
*/
@Controller
public class StartController {

@RequestMapping("/")
public String mensaje() {

return "index";
}
}
19 changes: 19 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
logging.level.root=info

spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp



#Configuración de Base de Datos

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

#Url donde esta el servicio de tu mysql y el nombre de la base de datos
spring.datasource.url=jdbc:mysql://localhost:3306/boot_demo?useSSL=false&serverTimezone=Europe/Madrid

#Usuario y contrasena para tu base de datos descrita en la línea anterior
spring.datasource.username=boot_demo
spring.datasource.password=boot_demo

#[opcional]Imprime en tu consola todo el SQL.
spring.jpa.show-sql = true
12 changes: 12 additions & 0 deletions src/main/webapp/WEB-INF/views/index.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hola</title>
</head>
<body>
Hola con Spring Boot
</body>
</html>

0 comments on commit 757e5f2

Please sign in to comment.