book-microservices-v2 / chapter05 Goto Github PK
View Code? Open in Web Editor NEWLearn Microservices with Spring Boot (2nd edition) - Chapter 5
Home Page: https://tpd.io/book-extra
Learn Microservices with Spring Boot (2nd edition) - Chapter 5
Home Page: https://tpd.io/book-extra
Hi Moisés, when following chapter 5 I came accross the issue, that
import javax.persistence.*;
did not work (javax.persistence cannot be resolved). I added the following dependency in pom.xml which solved the problem:
`<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>`
Did I miss something when following the book. I am not aware that it is mentioned at some place to add this dependency.
Thanks and best regards,
Matthias
I tried to overwrite the default user id and password for the h2 database by providing own credentials. To do so I added to the application.properties file these two lines
spring.datasource.user=myuser spring.datasource.password=pw
Via the h2-console I created that user as well. I can log-on to the database with the new user and its password without any problem.
However, when starting the multiplication service, I am getting this error:
org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Falscher Benutzername oder Passwort Wrong user name or password [28000-214]
How can it be if I can log-on to the console with "myuser" and password = "pw" without any problem?
When removing the two lines from the application.properties file it works again as the defaults apply (no user id, no password).
Thanks for your help,
Matthias
Hi Moisés,
After the introduction of the Repositories for the Users and Attempts, the /attempts endpoint does not work anymore. When calling it like this:
http POST :8080/attempts factorA=58 factorB=92 userAlias=matthias guess=5303
I am getting this response:
{"timestamp"}
There is even no http-code.
I also try it via Postman using this payload:
{
"factorA":20,
"factorB":50,
"userAlias":"matthias",
"guess":1000
}
Here, I am getting the same response as before and can see that there is an internal server error but without any details.
I double checked against your code in Git Hub, and cannot find a problem.
Before I added the Json Configuration, I got this error message:
could not prepare statement; SQL [select u1_0.id, u1_0.alias from user u1_0 where u1_0.alias=?]
Any idea what I am doing wrong?
Thanks and best regards,
Matthias
Hi-
Hibernate ran into an issue while trying to create the User table. It gave an error message that indicated that User was a reerved word. So following hibernate convention I backticked the table name User
and then it worked. I was wondering if anybody else had the same issue ?
Hi Moisés, once I added this code
package microservices.book.multiplication.challenge;
import org.springframework.data.repository.CrudRepository;
import java.util.List;
public interface ChallengeAttemptRepository extends CrudRepository<ChallengeAttempt, Long> {
/**
* @return the last 10 attempts for a given user, identified by their alias.
*/
List<ChallengeAttempt> findTop10ByUserAliasOrderByIdDesc(String userAlias);
}
This is my repository: https://github.com/wagenbm/LearnMicroservices.git
I cannot run the application anymore. This is the console output I get when running the application:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.1:run (default-cli) on project multiplication: Process terminated with exit code: 1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.1:run (default-cli) on project multiplication: Process terminated with exit code: 1
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:375)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:578)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:578)
at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:47)
at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:156)
at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:72)
Caused by: org.apache.maven.plugin.MojoExecutionException: Process terminated with exit code: 1
at org.springframework.boot.maven.JavaProcessExecutor.run (JavaProcessExecutor.java:74)
at org.springframework.boot.maven.RunMojo.run (RunMojo.java:68)
at org.springframework.boot.maven.AbstractRunMojo.run (AbstractRunMojo.java:218)
at org.springframework.boot.maven.AbstractRunMojo.execute (AbstractRunMojo.java:205)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:578)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
at java.lang.reflect.Method.invoke (Method.java:578)
at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:47)
at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:156)
at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:72)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
I do not get what exactly the issue with the interface is. When removing the interface, it works again.
Thanks and best regards,
Matthias
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.