Spring boot connects to the bank but does not generate the mapped tables ... In the example below, I'll put the password wrong, see the return:
dataSource.setPassword("");
2018-06-29 00: 26: 46.322 INFO 13612 --- [restartedMain] org.hibernate.dialect.Dialect: HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect 2018-06-29 00: 26: 46,322 INFO 13612 --- [restartedMain] o.h.e.j.e.i.LobCreatorBuilderImpl: HHH000422: Disabling contextual LOB creation as connection was null 2018-06-29 00: 26: 46,348 ERROR 13612 --- [restartedMain] org.hibernate.hql.spi.id.IdTableHelper: Unable to obtain JDBC Connection
Now with the correct password it does not generate any errors:
:: Spring Boot :: (v2.0.3.RELEASE)
2018-06-29 00:28:51.398 INFO 13612 --- [ restartedMain] c.e.eventoapp.EventoappApplication : Starting EventoappApplication on home with PID 13612 (C:\Users\Saulo\Documents\workspace\eventoapp\target\classes started by Saulo in C:\Users\Saulo\Documents\workspace\eventoapp)
2018-06-29 00:28:51.398
INFO 13612 --- [ restartedMain] c.e.eventoapp.EventoappApplication : No active profile set, falling back to default profiles: default
2018-06-29 00:28:51.400
INFO 13612 --- [ restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@40a6ca4f: startup date [Fri Jun 29 00:28:51 BRT 2018]; root of context hierarchy
2018-06-29 00:28:52.053 INFO 13612 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$a8915e9e] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-06-29 00:28:52.230 INFO 13612 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-06-29 00:28:52.231 INFO 13612 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-06-29 00:28:52.231 INFO 13612 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-06-29 00:28:52.269 INFO 13612 --- [ost-startStop-1] o.a.c.c.C.[Tomcat-2].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-06-29 00:28:52.269 INFO 13612 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 869 ms
2018-06-29 00:28:52.296 INFO 13612 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-06-29 00:28:52.297 INFO 13612 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-06-29 00:28:52.297 INFO 13612 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-06-29 00:28:52.297 INFO 13612 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-06-29 00:28:52.297 INFO 13612 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-06-29 00:28:52.344 INFO 13612 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-06-29 00:28:52.344 INFO 13612 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-06-29 00:28:52.397 INFO 13612 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
2018-06-29 00:28:52.890 INFO 13612 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-06-29 00:28:52.903 INFO 13612 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-06-29 00:28:52.955 INFO 13612 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@40a6ca4f: startup date [Fri Jun 29 00:28:51 BRT 2018]; root of context hierarchy
2018-06-29 00:28:52.960 WARN 13612 --- [ restartedMain] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2018-06-29 00:28:52.968 INFO 13612 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/cadastrarEvento]}" onto public java.lang.String com.eventoapp.eventoapp.controller.EventoController.form()
2018-06-29 00:28:52.969 INFO 13612 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String com.eventoapp.eventoapp.controller.indexController.index()
2018-06-29 00:28:52.970 INFO 13612 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-06-29 00:28:52.970 INFO 13612 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-06-29 00:28:52.979 INFO 13612 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-06-29 00:28:52.979 INFO 13612 --- [ restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-06-29 00:28:53.019 INFO 13612 --- [ restartedMain] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page template: index
2018-06-29 00:28:53.086 INFO 13612 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2018-06-29 00:28:53.096 INFO 13612 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-06-29 00:28:53.108 INFO 13612 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-06-29 00:28:53.109 INFO 13612 --- [ restartedMain] c.e.eventoapp.EventoappApplication : Started EventoappApplication in 1.752 seconds (JVM running for 1449.017)
2018-06-29 00:28:53.111 INFO 13612 --- [ restartedMain] .ConditionEvaluationDeltaLoggingListener : Condition evaluation unchanged
Below the classes I'm working on ...
import java.sql.SQLException;
import javax.sql.DataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.vendor.Database;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import oracle.jdbc.pool.OracleDataSource;
@Configuration
public class DataConfiguration {
@Bean
public DataSource dataSource() throws SQLException {
OracleDataSource dataSource = new OracleDataSource();
dataSource.setDriverType("oracle.jdbc.OracleDriver");
dataSource.setURL("jdbc:oracle:thin:@localhost:1521:XE");
dataSource.setUser("system");
dataSource.setPassword("root");
dataSource.setImplicitCachingEnabled(true);
dataSource.setFastConnectionFailoverEnabled(true);
return dataSource;
}
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
adapter.setDatabase(Database.ORACLE);
adapter.setShowSql(true);
adapter.setGenerateDdl(true);
adapter.setDatabasePlatform("org.hibernate.dialect.Oracle10gDialect");
adapter.setPrepareConnection(true);
return adapter;
}
Mapped Class:
import javax.persistence.Id
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
@Entity
public class Evento implements Serializable{
private static final long serialVersionUID = 1L;
@Id @GeneratedValue(strategy = GenerationType.AUTO)
private long codigo;
private String nome;
private String local;
private String data;
private String horario;
public long getCodigo() {
return codigo;
}
public void setCodigo(long codigo) {
this.codigo = codigo;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getLocal() {
return local;
}
public void setLocal(String local) {
this.local = local;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public String getHorario() {
return horario;
}
public void setHorario(String horario) {
this.horario = horario;
}
}
Detail, I already tried configuring the application.properties and gave the same result.