файлы конфигурации

This commit is contained in:
parap 2023-05-22 03:41:22 +04:00
parent 8824130025
commit 0a0686973e
2 changed files with 43 additions and 0 deletions
src/main/java/org/dbms/configuration

@ -0,0 +1,23 @@
package org.dbms.configuration;
import java.sql.Connection;
import java.sql.SQLException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
@Configuration
public class JDBCConection {
@Bean
public Connection getConnection(JdbcTemplate jdbcTemplate) {
Connection connection = null;
try {
connection = jdbcTemplate.getDataSource().getConnection();
} catch (SQLException e) {
e.printStackTrace();
}
return connection;
}
}

@ -0,0 +1,20 @@
package org.dbms.configuration;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
class WebConfiguration implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("*");
}
}