I am trying to connect my web application to MySQL. Spring Boot is not detecting the database but can connect to the server. Can someone lead me in the right direction so it can detect the schema. With the #Entity annotation, it should auto create a table in the database as "User". It should also say in the console "Database available" I have tried looking online but to no avail. Any help would be appreciated!
This is my application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/espersdb
spring.datasource.username=root
spring.datasource.password=password
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=none
This is my console
2020-12-27 03:32:47.859 INFO 26012 --- [ restartedMain] c.D.E.E.EspersWebsiteApplication : Starting EspersWebsiteApplication using Java 14.0.2 on DESKTOP-01JT4QR with PID 26012 (C:\Users\Donobuz\Documents\Espers_Website\target\classes started by Donobuz in C:\Users\Donobuz\Documents\Espers_Website)
2020-12-27 03:32:47.862 INFO 26012 --- [ restartedMain] c.D.E.E.EspersWebsiteApplication : No active profile set, falling back to default profiles: default
2020-12-27 03:32:47.913 INFO 26012 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-12-27 03:32:47.913 INFO 26012 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-12-27 03:32:48.510 INFO 26012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2020-12-27 03:32:48.511 INFO 26012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JDBC repositories in DEFAULT mode.
2020-12-27 03:32:48.516 INFO 26012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 3 ms. Found 0 JDBC repository interfaces.
2020-12-27 03:32:48.523 INFO 26012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2020-12-27 03:32:48.523 INFO 26012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-12-27 03:32:48.529 INFO 26012 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 0 ms. Found 0 JPA repository interfaces.
2020-12-27 03:32:48.830 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.hateoas.config.HateoasConfiguration' of type [org.springframework.hateoas.config.HateoasConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.833 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'relProviderPluginRegistry' of type [org.springframework.plugin.core.support.PluginRegistryFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.839 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'relProviderPluginRegistry' of type [org.springframework.plugin.core.OrderAwarePluginRegistry] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.842 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean '_relProvider' of type [org.springframework.hateoas.server.core.DelegatingLinkRelationProvider] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.847 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'messageResolver' of type [org.springframework.hateoas.mediatype.MessageSourceResolver] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.848 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.data.web.config.SpringDataJacksonConfiguration' of type [org.springframework.data.web.config.SpringDataJacksonConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.851 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonGeoModule' of type [org.springframework.data.geo.GeoModule] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.861 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration' of type [org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.863 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.864 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.872 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties' of type [org.springframework.boot.autoconfigure.jackson.JacksonProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.873 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'standardJacksonObjectMapperBuilderCustomizer' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration$StandardJackson2ObjectMapperBuilderCustomizer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.875 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$ParameterNamesModuleConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$ParameterNamesModuleConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.876 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'parameterNamesModule' of type [com.fasterxml.jackson.module.paramnames.ParameterNamesModule] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.877 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.881 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jsonComponentModule' of type [org.springframework.boot.jackson.JsonComponentModule] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.883 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonObjectMapperBuilder' of type [org.springframework.http.converter.json.Jackson2ObjectMapperBuilder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.888 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'spring.data.rest-org.springframework.boot.autoconfigure.data.rest.RepositoryRestProperties' of type [org.springframework.boot.autoconfigure.data.rest.RepositoryRestProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.889 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'springBootRepositoryRestConfigurer' of type [org.springframework.boot.autoconfigure.data.rest.SpringBootRepositoryRestConfigurer] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.890 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'configurerDelegate' of type [org.springframework.data.rest.webmvc.config.RepositoryRestConfigurerDelegate] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.896 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration' of type [org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.902 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'stringHttpMessageConverter' of type [org.springframework.http.converter.StringHttpMessageConverter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.903 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.http.JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration' of type [org.springframework.boot.autoconfigure.http.JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.903 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration' of type [org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.907 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonObjectMapperBuilder' of type [org.springframework.http.converter.json.Jackson2ObjectMapperBuilder] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.929 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'jacksonObjectMapper' of type [com.fasterxml.jackson.databind.ObjectMapper] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.934 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'mappingJackson2HttpMessageConverter' of type [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:48.935 INFO 26012 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration' of type [org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-27 03:32:49.190 INFO 26012 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-12-27 03:32:49.197 INFO 26012 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-12-27 03:32:49.197 INFO 26012 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41]
2020-12-27 03:32:49.278 INFO 26012 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-12-27 03:32:49.279 INFO 26012 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1364 ms
2020-12-27 03:32:49.512 INFO 26012 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-12-27 03:32:49.546 INFO 26012 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.25.Final
2020-12-27 03:32:49.620 INFO 26012 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2020-12-27 03:32:49.682 INFO 26012 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-12-27 03:32:49.924 INFO 26012 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-12-27 03:32:49.933 INFO 26012 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2020-12-27 03:32:50.049 INFO 26012 --- [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-12-27 03:32:50.056 INFO 26012 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-12-27 03:32:50.135 WARN 26012 --- [ restartedMain] JpaBaseConfiguration$JpaWebConfiguration : 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
2020-12-27 03:32:50.374 INFO 26012 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-12-27 03:32:50.954 INFO 26012 --- [ restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#6707114e, org.springframework.security.web.context.SecurityContextPersistenceFilter#20e3d55, org.springframework.security.web.header.HeaderWriterFilter#10647f40, org.springframework.security.web.csrf.CsrfFilter#17135eb0, org.springframework.security.web.authentication.logout.LogoutFilter#297f9882, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#21beac54, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter#2741bf4a, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter#425f1341, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#5e42e0a, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#7df3f08, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#51e53a6e, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#666fe17e, org.springframework.security.web.session.SessionManagementFilter#46a96507, org.springframework.security.web.access.ExceptionTranslationFilter#7edc01a5, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#460056c3]
2020-12-27 03:32:51.017 INFO 26012 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 8081
2020-12-27 03:32:51.050 INFO 26012 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2020-12-27 03:32:51.059 INFO 26012 --- [ restartedMain] c.D.E.E.EspersWebsiteApplication : Started EspersWebsiteApplication in 3.585 seconds (JVM running for 4.305)
2020-12-27 03:33:11.148 INFO 26012 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-12-27 03:33:11.149 INFO 26012 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-12-27 03:33:11.151 INFO 26012 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 2 ms
This is my DTO / Entity
package entities;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.validation.constraints.Email;
import java.time.Instant;
#Entity
#Data
#NoArgsConstructor
#AllArgsConstructor
public class User {
#Id
#GeneratedValue(strategy = IDENTITY)
private Long userID;
private String username;
private String password;
#Email
private String email;
private Instant createdDate;
private boolean enabled;
}
My User Repository
package repos;
import entities.User;
import org.springframework.data.repository.CrudRepository;
public interface UserRepository extends CrudRepository<User, Long> {
}
Lastly, this is my 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.Donobuz.Espers</groupId>
<artifactId>Espers_Website</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Espers_Website</name>
<description>A web application with many features to help gamers</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</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-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.22</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have figured out the answer:
I must declare spring.jpa.generate-ddl=true in the application properties as well. This then created the specified table correctly with correct columns
Try this spring.jpa.hibernate.ddl-auto=update
you please append some property in URL ( if you want to generate database automatically)
spring.datasource.url=jdbc:mysql://localhost:3306/espersdb?createDatabaseIfNotExist=true
spring.jpa.hibernate.ddl-auto=update
#Entity
#Data
#NoArgsConstructor
#AllArgsConstructor
#Table(name="User") // missing in your code
public class User {
//blah blah
}
Related
I have two modules in a spring boot microservice project which uses Axon framework. in the first module that is defined as a core project to keep the models, I have two classes (User and Role) which User class contains a list of roles:
////// The User and Role classes are in the first module
#Data
#AllArgsConstructor
#NoArgsConstructor
public class User {
private Integer id;
private String username;
private String password;
private String email;
private boolean enabled = false;
private boolean accountNonExpired = true;
private boolean credentialsNonExpired = true;
private boolean accountNonLocked = true;
private List<Role> roles;
}
#Data
#AllArgsConstructor
#NoArgsConstructor
public class Role {
private Integer id;
private String name;
}
In the second module I have added the dependency of the first module in POM file in order to access the User and Role classes:
<dependency>
<groupId>com.main</groupId>
<artifactId>core</artifactId>
<version>0.0.1</version>
</dependency>
In the second module when I am trying to create a User object, it gets error and does not save the user to the event store and complains about the Role class and specifically the List of Role. the following is a controller class in the second module that is creating a User object to send to Axon:
#RestController
#RequestMapping(path = "/api/v1/registerUser")
public class RegisterUserController {
private final CommandGateway commandGateway;
......
#PostMapping
public ResponseEntity<?> registerUser(#RequestBody User user)
{
Role role = new Role();
role.setId(1);
role.setName("Admin");
List<Role> roles = new ArrayList<Role>();
roles.add(role);
....
user.setRole(roles);
RegisterUserCommand command = new RegisterUserCommand();
command.setId(id);
command.setUser(user);
commandGateway.sendAndWait(command); /// Send the user to Axon
....
}
Important: when I tried to have just one module and put the user and role classes, controllers and all things in that module, it worked with no problem.
Stacktarce:
2022-08-16 12:06:44.463 INFO 29816 --- [ main] c.h.user.cmd.api.UserCommandApplication : Starting UserCommandApplication using Java 17.0.4 on DESKTOP-JUNLICE with PID 29816 (E:\Hawramgard_main\User_Management\user.cmd.api\target\classes started by Venos46131105 in E:\Hawramgard_main\User_Management)
2022-08-16 12:06:44.465 INFO 29816 --- [ main] c.h.user.cmd.api.UserCommandApplication : No active profile set, falling back to 1 default profile: "default"
2022-08-16 12:06:45.249 INFO 29816 --- [ main] o.s.c.a.ConfigurationClassPostProcessor : Cannot enhance #Configuration bean definition 'org.axonframework.springboot.autoconfig.EventProcessingAutoConfiguration' since its singleton instance has been created too early. The typical cause is a non-static #Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2022-08-16 12:06:45.360 INFO 29816 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean '(inner bean)#4a1e3ac1#31' of type [org.axonframework.spring.config.annotation.SpringContextParameterResolverFactoryBuilder$ClasspathParameterResolverFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-08-16 12:06:45.361 INFO 29816 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean '(inner bean)#4a1e3ac1#31' of type [org.axonframework.messaging.annotation.MultiParameterResolverFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-08-16 12:06:45.364 INFO 29816 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean '(inner bean)#4a31c2ee#31' of type [org.axonframework.spring.config.annotation.SpringBeanDependencyResolverFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-08-16 12:06:45.364 INFO 29816 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean '(inner bean)#7be71476' of type [org.axonframework.spring.config.annotation.SpringBeanParameterResolverFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-08-16 12:06:45.366 INFO 29816 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean '__axon-parameter-resolver-factory' of type [org.axonframework.spring.config.ApplicationContextLookupParameterResolverFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-08-16 12:06:45.366 INFO 29816 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean '__axon-parameter-resolver-factory' of type [org.axonframework.messaging.annotation.MultiParameterResolverFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-08-16 12:06:45.374 INFO 29816 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean '(inner bean)#7b7683d4' of type [org.axonframework.spring.config.annotation.SpringHandlerDefinitionBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-08-16 12:06:45.374 INFO 29816 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean '(inner bean)#7b7683d4' of type [org.axonframework.messaging.annotation.MultiHandlerDefinition] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-08-16 12:06:45.375 INFO 29816 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean '(inner bean)#3efedc6f' of type [org.axonframework.spring.config.annotation.SpringHandlerEnhancerDefinitionBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-08-16 12:06:45.375 INFO 29816 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean '(inner bean)#3efedc6f' of type [org.axonframework.messaging.annotation.MultiHandlerEnhancerDefinition] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-08-16 12:06:45.376 INFO 29816 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean '__axon-handler-definition' of type [org.axonframework.messaging.annotation.MultiHandlerDefinition] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2022-08-16 12:06:45.653 INFO 29816 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http)
2022-08-16 12:06:45.667 INFO 29816 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-08-16 12:06:45.667 INFO 29816 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.65]
2022-08-16 12:06:45.769 INFO 29816 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-08-16 12:06:45.769 INFO 29816 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1265 ms
2022-08-16 12:06:45.977 INFO 29816 --- [ main] o.a.s.a.XStreamAutoConfiguration : Initializing an XStream instance since none was found. The auto configuration base packages will be used as wildcards for the XStream security settings.
2022-08-16 12:06:46.083 INFO 29816 --- [ main] o.a.s.util.XStreamSecurityTypeUtility : Constructing wildcard type for base package [com.hawramgard.user.cmd.api].
2022-08-16 12:06:46.091 INFO 29816 --- [ main] o.a.serialization.ChainingConverter : ContentTypeConverter of type [class org.axonframework.serialization.xml.Dom4JToByteArrayConverter] is ignored. It seems to rely on a class that is not available in the class loader: org/dom4j/Document
2022-08-16 12:06:46.091 INFO 29816 --- [ main] o.a.serialization.ChainingConverter : ContentTypeConverter of type [class org.axonframework.serialization.xml.InputStreamToDom4jConverter] is ignored. It seems to rely on a class that is not available in the class loader: org/dom4j/Document
2022-08-16 12:06:46.092 INFO 29816 --- [ main] o.a.serialization.ChainingConverter : ContentTypeConverter of type [class org.axonframework.serialization.xml.XomToStringConverter] is ignored. It seems to rely on a class that is not available in the class loader: nu/xom/Document
2022-08-16 12:06:46.092 INFO 29816 --- [ main] o.a.serialization.ChainingConverter : ContentTypeConverter of type [class org.axonframework.serialization.xml.InputStreamToXomConverter] is ignored. It seems to rely on a class that is not available in the class loader: nu/xom/ParsingException
2022-08-16 12:06:46.145 WARN 29816 --- [ main] .s.s.UserDetailsServiceAutoConfiguration :
2022-08-16 12:06:46.309 INFO 29816 --- [ main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter#1ee5632d, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#52a7928a, org.springframework.security.web.context.SecurityContextPersistenceFilter#2f9dda71, org.springframework.security.web.header.HeaderWriterFilter#5fffb692, org.springframework.web.filter.CorsFilter#563ccd31, org.springframework.security.web.authentication.logout.LogoutFilter#739831a4, org.springframework.security.web.authentication.www.BasicAuthenticationFilter#39023dbf, org.springframework.security.web.savedrequest.RequestCacheAwareFilter#7f5fcfe9, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#67688110, org.springframework.security.web.authentication.AnonymousAuthenticationFilter#72465eb2, org.springframework.security.web.session.SessionManagementFilter#6282b9f5, org.springframework.security.web.access.ExceptionTranslationFilter#79d7035, org.springframework.security.web.access.intercept.FilterSecurityInterceptor#2bab618]
2022-08-16 12:06:46.730 INFO 29816 --- [ main] i.a.a.c.impl.AxonServerManagedChannel : Requesting connection details from localhost:8124
2022-08-16 12:06:47.147 INFO 29816 --- [ main] i.a.a.c.impl.AxonServerManagedChannel : Successfully connected to localhost:8124
2022-08-16 12:06:47.158 INFO 29816 --- [ main] i.a.a.connector.impl.ControlChannelImpl : Connected instruction stream for context 'default'. Sending client identification
2022-08-16 12:06:47.170 INFO 29816 --- [ main] i.a.a.c.command.impl.CommandChannelImpl : CommandChannel for context 'default' connected, 0 command handlers registered
2022-08-16 12:06:47.174 INFO 29816 --- [ main] i.a.a.c.command.impl.CommandChannelImpl : Registered handler for command 'com.hawramgard.user.cmd.api.commands.RegisterUserCommand' in context 'default'
2022-08-16 12:06:47.179 INFO 29816 --- [ main] i.a.a.c.command.impl.CommandChannelImpl : Registered handler for command 'com.hawramgard.user.cmd.api.commands.RemoveUserCommand' in context 'default'
2022-08-16 12:06:47.180 INFO 29816 --- [ main] i.a.a.c.command.impl.CommandChannelImpl : Registered handler for command 'com.hawramgard.user.cmd.api.commands.UpdateUserCommand' in context 'default'
2022-08-16 12:06:47.200 INFO 29816 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8081 (http) with context path ''
2022-08-16 12:06:47.215 INFO 29816 --- [ main] c.h.user.cmd.api.UserCommandApplication : Started UserCommandApplication in 3.056 seconds (JVM running for 5.815)
2022-08-16 12:07:13.096 INFO 29816 --- [nio-8081-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-08-16 12:07:13.096 INFO 29816 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2022-08-16 12:07:13.096 INFO 29816 --- [nio-8081-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 0 ms
RegisterUserCommand(id=1638, user=com.hawramgard.user.core.models.User#7738b41d)
org.axonframework.commandhandling.CommandExecutionException: com.hawramgard.user.core.models.Role
When Jackson needs to serialize a list, it loses the type information and is unable to deserialize it. This can be solved in Axon Framework using the following configuration:
#Configuration
public class SerializerConfig {
#Bean
public Serializer jacksonSerializer(ObjectMapper objectMapper) {
return JacksonSerializer.builder()
.defaultTyping()
.build();
}
}
Note that this can also be solved using #JsonTypeInfo annotation. For more information, see the javadoc of the defaultTyping() method on the JacksonSerializer:
Configures the underlying ObjectMapper to include type information when serializing Java objects into JSON. Specifically, it calls ObjectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping) method, using ObjectMapper.DefaultTyping.NON_CONCRETE_AND_ARRAYS. This can be toggled on to allow java.util.Collections of objects, for example query java.util.List responses, to automatically include the types without require the use of com.fasterxml.jackson.annotation.JsonTypeInfo on the objects themselves.
I am trying to deploy springboot application with mysql as database on openshift platform. I have pulled the database image and its running. But when i pulled the spring application, it is deployed and connecting to database. But, still i am not able to hit the endpoint and when i check the pods i am getting Crashloopback error.
Can anyone help me to get it resolve.
NAME READY STATUS RESTARTS AGE
mysql-3-deploy 0/1 Completed 0 43m
mysql-3-p2rb6 1/1 Running 0 43m
partydetailswithdb-1-deploy 0/1 Completed 0 46m
partydetailswithdb-2-cs8jp 0/1 CrashLoopBackOff 12 41m
partydetailswithdb-2-deploy 0/1 Completed 0 41m
2019-09-06 05:19:09.519 INFO 1 --- [ main] c.c.openbanking.PartydetailsApplication : Starting PartydetailsApplication
v0.0.1-SNAPSHOT on partydetailswithdb-2-cs8jp with PID 1 (/partyv2.jar started
by 1000880000 in /)
2019-09-06 05:19:09.532 INFO 1 --- [ main] c.c.openbanking.PartydetailsApplication : No active profile set, falling back to default profiles: default
2019-09-06 05:19:09.817 INFO 1 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#16b4a017: startup date [Fri Sep 06 05:19:09 GMT 2019]; root of context hierarchy
2019-09-06 05:19:15.003 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'webServiceConfig' of type [com.cg.openbanking.configuration.WebServiceConfig$$EnhancerBySpringCGLIB$$1f075603] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-06 05:19:15.015 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$b5052733] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-06 05:19:15.143 INFO 1 --- [ main] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2019-09-06 05:19:15.237 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'io.opentracing.contrib.spring.cloud.async.DefaultAsyncAutoConfiguration$DefaultTracedAsyncConfigurerSupport' of type [io.opentracing.contrib.spring.cloud.async.DefaultAsyncAutoConfiguration$DefaultTracedAsyncConfigurerSupport$$EnhancerBySpringCGLIB$$55d5a4ef] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-06 05:19:15.600 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$106d6234] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-06 05:19:16.139 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'io.opentracing.contrib.spring.cloud.async.DefaultAsyncAutoConfiguration' of type [io.opentracing.contrib.spring.cloud.async.DefaultAsyncAutoConfiguration$$EnhancerBySpringCGLIB$$56f3758c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-06 05:19:18.896 INFO 1 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9999 (http)
2019-09-06 05:19:19.108 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-09-06 05:19:19.109 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.35
2019-09-06 05:19:19.202 INFO 1 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2019-09-06 05:19:19.501 INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-09-06 05:19:19.501 INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 9692 ms
2019-09-06 05:19:19.895 INFO 1 --- [ost-startStop-1] o.c.s.w.a.ServerTracingAutoConfiguration : Creating FilterRegistrationBean bean with TracingFilter mapped to [/], skip pattern is "/api-docs.|/autoconfig|/configprops|/dump|/health|/info|/metrics.|/mappings|/swagger.|..png|..css|..js|..html|/favicon.ico|/hystrix.stream"
2019-09-06 05:19:20.131 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'tracingFilter' to urls: [/*]
2019-09-06 05:19:20.132 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-09-06 05:19:20.132 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-09-06 05:19:20.132 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-09-06 05:19:20.132 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2019-09-06 05:19:20.132 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet messageDispatcherServlet mapped to [/ws/*]
2019-09-06 05:19:20.133 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2019-09-06 05:19:21.301 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-09-06 05:19:22.303 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-09-06 05:19:22.825 INFO 1 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2019-09-06 05:19:22.933 INFO 1 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-09-06 05:19:23.230 INFO 1 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2019-09-06 05:19:23.234 INFO 1 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
So I've been trying to do the example from spring's official guide on connecting Spring with MySQL (https://spring.io/guides/gs/accessing-data-mysql/)
I didn't follow it 100% since I'm using STS for my overall project. The thing is when I use POSTMAN or just my browser to send data
such as :
localhost:8000/demo/add?name=First&email=someemail#someemailprovider.com
I get the error not found.
The java code is the same as in the guide . My application.properties is this:
server.port=8000
spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:mysql://localhost:3306/db_example
spring.datasource.username=springuser
spring.datasource.password=ThePassword
and my pom.xml is this
<?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>com.example</groupId>
<artifactId>dbDemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>dbDemo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</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-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>
The answer from my browser is:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing
this as a fallback.
Tue Jul 10 21:15:52 EEST 2018
There was an unexpected error (type=Not Found, status=404).
No message available
And from postman :
{
"timestamp": "2018-07-10T18:08:28.208+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/demo/add"
}
The log from spring's console is :
:: Spring Boot :: (v2.0.3.RELEASE)
2018-07-10 20:32:36.453 INFO 7815 --- [ main] com.example.demo.DbDemoApplication : Starting DbDemoApplication on max-kans with PID 7815 (/home/max/Desktop/Fetina/Earino/projectTL/softEngine/dbDemo/target/classes started by max in /home/max/Desktop/Fetina/Earino/projectTL/softEngine/dbDemo)
2018-07-10 20:32:36.496 INFO 7815 --- [ main] com.example.demo.DbDemoApplication : No active profile set, falling back to default profiles: default
2018-07-10 20:32:36.742 INFO 7815 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#2aa5fe93: startup date [Tue Jul 10 20:32:36 EEST 2018]; root of context hierarchy
2018-07-10 20:32:41.650 INFO 7815 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$5ab04215] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-10 20:32:42.775 INFO 7815 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8000 (http)
2018-07-10 20:32:43.344 INFO 7815 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-07-10 20:32:43.344 INFO 7815 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-07-10 20:32:44.326 INFO 7815 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2018-07-10 20:32:47.580 INFO 7815 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-07-10 20:32:47.581 INFO 7815 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 10868 ms
2018-07-10 20:32:48.187 INFO 7815 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-07-10 20:32:48.192 INFO 7815 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-10 20:32:48.193 INFO 7815 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-10 20:32:48.193 INFO 7815 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-07-10 20:32:48.193 INFO 7815 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-07-10 20:32:50.090 INFO 7815 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-07-10 20:32:54.757 INFO 7815 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-07-10 20:32:55.307 INFO 7815 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2018-07-10 20:32:55.640 INFO 7815 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2018-07-10 20:32:58.848 INFO 7815 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.2.17.Final}
2018-07-10 20:32:59.125 INFO 7815 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2018-07-10 20:33:00.513 INFO 7815 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2018-07-10 20:33:02.175 INFO 7815 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2018-07-10 20:33:03.329 INFO 7815 --- [ main] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#7a8406c2'
2018-07-10 20:33:03.331 INFO 7815 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2018-07-10 20:33:06.623 INFO 7815 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-10 20:33:08.065 INFO 7815 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#2aa5fe93: startup date [Tue Jul 10 20:32:36 EEST 2018]; root of context hierarchy
2018-07-10 20:33:08.206 WARN 7815 --- [ main] 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-07-10 20:33:08.322 INFO 7815 --- [ main] 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-07-10 20:33:08.324 INFO 7815 --- [ main] 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-07-10 20:33:08.368 INFO 7815 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-10 20:33:08.368 INFO 7815 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-07-10 20:33:09.610 INFO 7815 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-07-10 20:33:09.613 INFO 7815 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-07-10 20:33:09.622 INFO 7815 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2018-07-10 20:33:10.003 INFO 7815 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8000 (http) with context path ''
2018-07-10 20:33:10.154 INFO 7815 --- [ main] com.example.demo.DbDemoApplication : Started DbDemoApplication in 35.885 seconds (JVM running for 39.933)
2018-07-10 20:34:07.354 INFO 7815 --- [nio-8000-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-07-10 20:34:07.354 INFO 7815 --- [nio-8000-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2018-07-10 20:34:07.962 INFO 7815 --- [nio-8000-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 608 ms
My controller is pretty much identical to the one from spring's guide :
package hello;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import hello.User;
import hello.UserRepository;
#Controller // This means that this class is a Controller
#RequestMapping(path="/demo")
// This means URL's start with /demo (after Application path)
public class UserController {
#Autowired
// This means to get the bean called userRepository
// Which is auto-generated by Spring, we will use it to handle the data
private UserRepository userRepository;
#GetMapping(path="/add") // Map ONLY GET Requests
public #ResponseBody String addNewUser(#RequestParam String name,
#RequestParam String email) {
// #ResponseBody means the returned String is the response,
// not a view name
User n = new User();
n.setName(name);
n.setEmail(email);
userRepository.save(n);
return "Saved";
}
#GetMapping(path="/all")
public #ResponseBody Iterable<User> getAllUsers() {
// This returns a JSON or XML with the users
return userRepository.findAll();
}
}
Your #SpringBootApplication class is in the package com.example.demo (according to the startup log), but your #Controller is in package hello. By default, Spring Boot won't auto-discover Spring classes that are outside the package the #SpringBootApplication class is in. Either move the UserController somewhere under the com.example.demo, or add #ComponentScan annotation targeting your hello package to the main Spring Boot app class.
I'm using spring boot 1.5.4, i'm following a tutorial where it shows that just by adding h2-console to the localhost:8080/ url you can access the console. But when i do that i have a 404 Whitelabel error.
These are the dependencies
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--WebJars-->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.5</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.2.1</version>
</dependency>
<!--jpa and database-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
And this is the spring boot console log
2017-07-19 01:35:25.222 INFO 8644 --- [ main] c.e.s.SpringBootTest00Application : Starting SpringBootTest00Application on DESKTOP-K8Q0B2R with PID 8644 (started by Talon in C:\Users\Talon\Desktop\java netbeans\01\springBootTest00)
2017-07-19 01:35:25.225 INFO 8644 --- [ main] c.e.s.SpringBootTest00Application : No active profile set, falling back to default profiles: default
2017-07-19 01:35:25.544 INFO 8644 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#37574691: startup date [Wed Jul 19 01:35:25 CEST 2017]; root of context hierarchy
2017-07-19 01:35:27.236 INFO 8644 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-07-19 01:35:27.248 INFO 8644 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-07-19 01:35:27.249 INFO 8644 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.15
2017-07-19 01:35:27.378 INFO 8644 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-07-19 01:35:27.378 INFO 8644 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1838 ms
2017-07-19 01:35:27.578 INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-07-19 01:35:27.582 INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-07-19 01:35:27.584 INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-07-19 01:35:27.584 INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-07-19 01:35:27.584 INFO 8644 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-07-19 01:35:28.020 INFO 8644 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-07-19 01:35:28.037 INFO 8644 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2017-07-19 01:35:28.122 INFO 8644 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.12.Final}
2017-07-19 01:35:28.123 INFO 8644 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2017-07-19 01:35:28.180 INFO 8644 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-07-19 01:35:28.219 INFO 8644 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-07-19 01:35:28.321 INFO 8644 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2017-07-19 01:35:28.742 INFO 8644 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2017-07-19 01:35:28.757 INFO 8644 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
2017-07-19 01:35:28.809 INFO 8644 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-07-19 01:35:29.119 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#37574691: startup date [Wed Jul 19 01:35:25 CEST 2017]; root of context hierarchy
2017-07-19 01:35:29.203 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String com.example.springBootTest00.controllers.IndexController.index()
2017-07-19 01:35:29.205 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product],methods=[POST]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.saveOrUpdateProduct(com.example.springBootTest00.domain.Product)
2017-07-19 01:35:29.206 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product/edit/{id}]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.edit(java.lang.Integer,org.springframework.ui.Model)
2017-07-19 01:35:29.206 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product/new]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.newProduct(org.springframework.ui.Model)
2017-07-19 01:35:29.206 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product/delete/{id}]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.deleteProduct(java.lang.Integer,org.springframework.ui.Model)
2017-07-19 01:35:29.206 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/products]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.listProducts(org.springframework.ui.Model)
2017-07-19 01:35:29.206 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/product/{id}]}" onto public java.lang.String com.example.springBootTest00.controllers.ProductController.getProduct(java.lang.Integer,org.springframework.ui.Model)
2017-07-19 01:35:29.209 INFO 8644 --- [ main] 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.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-07-19 01:35:29.209 INFO 8644 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-07-19 01:35:29.243 INFO 8644 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-19 01:35:29.244 INFO 8644 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-19 01:35:29.284 INFO 8644 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-07-19 01:35:29.920 INFO 8644 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-07-19 01:35:29.983 INFO 8644 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-07-19 01:35:29.987 INFO 8644 --- [ main] c.e.s.SpringBootTest00Application : Started SpringBootTest00Application in 5.052 seconds (JVM running for 5.401)
I have some classes with #Service / #Controller working properly and all the requests are mapped to url strings other than h2-console. Should i import something else in the pom or configure something in application.properties ?
Writing in simple Steps:
In Application.properties file include
spring.h2.console.path=/h2
spring.h2.console.enabled=true
And in pom.xml Include devtools dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
re-package and open http://localhost:[port]/h2 you are all set
other properties you have to include is
spring.datasource.url=jdbc:h2:file:~/h2db
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
the file h2db will store in userprofile folder of windows
for example : C:\Users\[profile]
I am trying to run Spring boot application but I am facing a problem. Help me please. Why do I have this error?
pom.xml
<groupId>com.bwebmedia.laughtercounter</groupId>
<artifactId>laughtercounter</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>laughtercounter</name>
<description></description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.0.0</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.6.0</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</project>
`AppConfig
#Configuration
#EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
#ComponentScan
#EnableAsync
#EnableCaching
#EnableScheduling
public class AppConfig {
}
Application
#EnableDiscoveryClient
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
application.properties
server.port=8888
spring.main.banner-mode=off
#database config
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url= jdbc:postgresql://localhost:5432/laughterDB
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.jpa.hibernate.ddl-auto=create-drop
#rabbit config
rabbit.host=localhost
rabbit.port=5672
rabbit.username=guest
rabbit.password=guest
#60 sec
spring.datasource.hikari.connection-timeout=60000
# max 5
spring.datasource.hikari.maximum-pool-size=5
Controller
#RestController
public class ClientController {
final private ClientService clientService;
#Autowired
public ClientController(ClientService clientService) {
this.clientService = clientService;
}
#RequestMapping(value = "/create", method = RequestMethod.POST)
public void create(#RequestBody List<Client> client,
BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
throw new InvalidRequestException("Not correct request data");
}
clientService.create(client);
}
}
Model
#Data
#Builder
#AllArgsConstructor
#NoArgsConstructor
public class Client {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private int seat;
private String gender;
private int cameraId;
private int height;
private int topY;
private int width;
private int leftX;
private long smile;
}
Repository
#Repository
public interface ClientRepository extends JpaRepository<Client, Long> {
}
Service
#Service
#Slf4j
public class ClientServiceImpl implements ClientService {
private ClientRepository clientRepository;
#Autowired
public ClientServiceImpl(ClientRepository clientRepository) {
this.clientRepository = clientRepository;
}
#Override
public void create(List<Client> client) {
client.forEach(x -> clientRepository.save(x));
}
}
Error output
Connected to the target VM, address: '127.0.0.1:37019', transport: 'socket'
2017-03-02 17:47:09.286 INFO 8561 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#294e5088: startup date [Thu Mar 02 17:47:09 EET 2017]; root of context hierarchy
2017-03-02 17:47:10.066 INFO 8561 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-03-02 17:47:10.188 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'configurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$332fe413] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:11.174 INFO 8561 --- [ main] c.bwebmedia.laughtercounter.Application : No active profile set, falling back to default profiles: default
2017-03-02 17:47:11.212 INFO 8561 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#3aefae67: startup date [Thu Mar 02 17:47:11 EET 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext#294e5088
2017-03-02 17:47:14.472 INFO 8561 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'dataSource' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Tomcat; factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]]
2017-03-02 17:47:14.546 WARN 8561 --- [ main] o.s.c.a.ConfigurationClassPostProcessor : Cannot enhance #Configuration bean definition 'refreshScope' since its singleton instance has been created too early. The typical cause is a non-static #Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.
2017-03-02 17:47:14.947 INFO 8561 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=ffa7c2d3-1b2b-3c4f-b2a5-e20a48541c23
2017-03-02 17:47:15.024 INFO 8561 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2017-03-02 17:47:15.293 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration' of type [class org.springframework.amqp.rabbit.annotation.RabbitBootstrapConfiguration$$EnhancerBySpringCGLIB$$dd819f44] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.390 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.retry.annotation.RetryConfiguration' of type [class org.springframework.retry.annotation.RetryConfiguration$$EnhancerBySpringCGLIB$$cd9793b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.462 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$1715e116] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.574 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cache.annotation.ProxyCachingConfiguration' of type [class org.springframework.cache.annotation.ProxyCachingConfiguration$$EnhancerBySpringCGLIB$$60281734] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.649 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration' of type [class org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration$$EnhancerBySpringCGLIB$$549bdbd8] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.740 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.cache-org.springframework.boot.autoconfigure.cache.CacheProperties' of type [class org.springframework.boot.autoconfigure.cache.CacheProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.764 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.cache.CacheManagerCustomizers' of type [class org.springframework.boot.autoconfigure.cache.CacheManagerCustomizers] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.775 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.cache.SimpleCacheConfiguration' of type [class org.springframework.boot.autoconfigure.cache.SimpleCacheConfiguration$$EnhancerBySpringCGLIB$$f6374eb9] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.833 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'cacheManager' of type [class org.springframework.cache.concurrent.ConcurrentMapCacheManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:15.835 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'cacheAutoConfigurationValidator' of type [class org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration$CacheManagerValidator] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:16.048 INFO 8561 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [class org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$332fe413] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-03-02 17:47:17.019 INFO 8561 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8888 (http)
2017-03-02 17:47:17.044 INFO 8561 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-03-02 17:47:17.047 INFO 8561 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.5
2017-03-02 17:47:17.303 INFO 8561 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-03-02 17:47:17.304 INFO 8561 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 6092 ms
2017-03-02 17:47:17.878 INFO 8561 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-03-02 17:47:17.887 INFO 8561 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-03-02 17:47:17.888 INFO 8561 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-03-02 17:47:17.889 INFO 8561 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-03-02 17:47:17.890 INFO 8561 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-03-02 17:47:18.914 INFO 8561 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2017-03-02 17:47:18.961 INFO 8561 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2017-03-02 17:47:19.407 INFO 8561 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.0.11.Final}
2017-03-02 17:47:19.413 INFO 8561 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2017-03-02 17:47:19.417 INFO 8561 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2017-03-02 17:47:19.646 INFO 8561 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2017-03-02 17:47:20.841 INFO 8561 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL94Dialect
2017-03-02 17:47:21.174 INFO 8561 --- [ main] o.h.e.j.e.i.LobCreatorBuilderImpl : HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
2017-03-02 17:47:21.179 INFO 8561 --- [ main] org.hibernate.type.BasicTypeRegistry : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType#3b4f1eb
2017-03-02 17:47:21.569 INFO 8561 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2017-03-02 17:47:21.572 INFO 8561 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
2017-03-02 17:47:21.633 INFO 8561 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2017-03-02 17:47:21.731 WARN 8561 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'clientController' defined in file [/home/spanky/IdeaProjects/laughter-counter-server/target/classes/com/bwebmedia/laughtercounter/controller/ClientController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'clientServiceImpl' defined in file [/home/spanky/IdeaProjects/laughter-counter-server/target/classes/com/bwebmedia/laughtercounter/service/impl/ClientServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean found for dependency [com.bwebmedia.laughtercounter.repository.ClientRepository]: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2017-03-02 17:47:21.732 INFO 8561 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-03-02 17:47:21.732 INFO 8561 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2017-03-02 17:47:21.733 INFO 8561 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
2017-03-02 17:47:21.745 INFO 8561 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2017-03-02 17:47:21.797 INFO 8561 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-03-02 17:47:22.103 ERROR 8561 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.bwebmedia.laughtercounter.service.impl.ClientServiceImpl required a bean of type 'com.bwebmedia.laughtercounter.repository.ClientRepository' that could not be found.
Action:
Consider defining a bean of type 'com.bwebmedia.laughtercounter.repository.ClientRepository' in your configuration.
Disconnected from the target VM, address: '127.0.0.1:37019', transport: 'socket'
Process finished with exit code 1
Error in not #Autowired repository. Not find models and other parts. I'm use Linux(Ubuntu dist). Sometimes write error with context. Why I am facing this error?
Do not exclude DataSourceAutoConfiguration.class in your AppConfig class.