Coder Social home page Coder Social logo

book-microservices-v2 / chapter05 Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 13.0 385 KB

Learn Microservices with Spring Boot (2nd edition) - Chapter 5

Home Page: https://tpd.io/book-extra

HTML 5.26% CSS 1.11% JavaScript 37.55% Java 56.07%
3-layer 3-tier-architecture hibernate-jpa java jpa microservice-architecture microservice-example query-methods spring-boot

chapter05's People

Contributors

mechero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

chapter05's Issues

javax.persistence missing in classpath

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

Issue with creating the user table name

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 ?

/attempts endpoint does not work after introduction of Repositories

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.

image

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

Issue with ChallengeAttemptRepository interface

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

Changing user id and password for H2 database does not work

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.