-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Home
You have a number of options for getting help with your Spring Framework 5 course. See this page for how to get help.
Please see this page for IDE related questions.
See this page for questions related to which Java version to use.
- Getting error - Whitelabel Error Page - This application has no explicit mapping for /error...
- Project wont start. Getting error: java.net.BindException: Address already in use
- Database tables missing in H2 Database console.
- Multi-Module Maven Project has error 'can't find Main class'
- Getting an error, but cannot find what is different from lesson source code.
- Error - java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
- JUnit 5 Tests are not running from Maven
- Spring Pet Clinic - CSS is not rendered, page is not styled.
- Error 'No qualifying Bean of type [Java class name] found for dependency...'
- CircleCI Maven Error - The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
- How to use the source code of the course?
- Video quality is not good or video is blur
- Compilation error in project when using Gradle in Intellij
- Maven executable not found at: <MAVEN_PATH>\bin\mvn.bat
- How to display mappings of incoming requests to controller handler methods in IntelliJ Console?
- Spring Pet Clinic in Java 8 Unable to find main class
- The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured
- Cannot prepare the release because you have local modifications: pom.xml:modified
- Getting error cannot find templates
This is a generic error page generated by Spring Boot. The root cause can be many different things.
If you see this web page, you need to view the Spring Boot console messages to determine the root cause.
May see in console log:
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.
This means another application is already running on port 8080. You need to find and stop the other application.
By default Spring Boot will configure the datasource as jdbc:h2:mem:testdb
However, if running the H2 database console for the first time, the datasource URL is jdbc:h2:~/test
What happens is the H2 database console is connecting to a different instance of the H2 database console, thus you will not see the database tables.
Solution: When connecting in the H2 Database Console, change the JDBC URL to jdbc:h2:mem:testdb
Spring Boot is trying to build an executable fat JAR with dependencies for a module that should be a normal JAR, thus looking for the main class for the JAR manifest file.
Solution: You need to tell the Spring Boot Maven Plugin to not repackage the jar.
Add the following property to the Maven module you wish packaged as a normal jar.
<properties>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>
Note: For Spring Boot 2.1 or Higher! This configuration has changed from earlier versions of Spring Boot.
Sometimes it can be a very small difference. You can use Git to report the differences between your code and the example source code for the lesson.
Note: This will only work if you've forked the original source code example to your GitHub repository.
- Commit all of your changes.
- Add remote for original repo -
git remote add sfgRepo github_url
- Fetch remote -
git fetch sfgRepo
- Run diff -
git diff HEAD..sfgRepo/master
<- update branch name from master to desired branch for lesson
You are running Java 9+ and have not added the JAXB dependencies.
Add the following dependencies to your Maven POM:
<properties>
<jaxb.version>2.3.0</jaxb.version>
</properties>
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb.version}</version>
</dependency>
</dependencies>
There are several reasons for this, and a lot of bad advice on the internet.
Please see this blog post!
The CSS resources are generated with Maven. Thus if the project is cleaned, not built, or re-generated with IntelliJ the CSS resources will not exist.
Solution: Just build the project with Maven. mvn clean package
Spring is looking for a bean of a specific type in the context, but is unable to find it. Error is because Spring has not been configured to create a bean for the Java class indicated in the message.
This may be due to several different reasons, but when troubleshooting - keep in mind Spring is telling you that Java class is missing from the context. You need to tell Spring to create a bean of that type.
Try the following:
- Make sure you have a bean of the type configured.
- Is the missing Java class annotated with a Spring stereotype - @Component, @Controller, @RestController, @Service, @Repository?
- Or has the bean been declared in a Java configuration class using the @Bean annotation?
- Is the package of the Java class or configuration class being scanned?
- By default, Spring Boot will do a component scan of the package of the main application class, and all sub-packages. A common mistake is to create a package outside of this package structure. (thus, Spring does not 'see' the configuration)
- If the component is not under the package of the main application class, use the @ComponentScan annotation. See this link for additional information.
CircleCI Maven Error - The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
Problem Maven fails to build on CircleCI with the following error:
[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /home/circleci/repo && /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -jar /home/circleci/repo/target/surefire/surefirebooter2185025882795471569.jar /home/circleci/repo/target/surefire 2019-01-06T20-41-42_280-jvmRun1 surefire1322664035589975057tmp surefire_01251624383929836459tmp
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /home/circleci/repo && /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -jar /home/circleci/repo/target/surefire/surefirebooter2185025882795471569.jar /home/circleci/repo/target/surefire 2019-01-06T20-41-42_280-jvmRun1 surefire1322664035589975057tmp surefire_01251624383929836459tmp
[ERROR] Error occurred in starting fork, check output in log
[ERROR] Process Exit Code: 1
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:669)
This is a problem with the Maven Surefire plugin running on newer releases of Java 8. Solution: You need to add the following to your Maven POM to configure the Maven Surefire plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
Source code for this course is in Github. Code-centric lectures have a Resources Available
link on the Udemy player.
On clicking it, you will find Starting Source
and Ending Source
links for that Lecture.
Starting Source
points to the Github repo branch that contains the starter code for the lecture.
Ending Source
points to the Github repo branch that contains the final code of the lecture.
To get the best out of the course:
- Fork/clone the repo.
- Checkout the Starting Source branch
- Write the code along with the lecture.
- If you get stuck, refer the Ending Source
Videos go through quality checks before getting uploaded to Udemy. Therefore, if your viewing experience is not good, it might be due to the following reasons:
- Low Internet Bandwith: Check your Internet Connectivity because Udemy will serve video in lower resolution for low Internet bandwidth.
- Incorrect settings in Udemy Video Player: Adjust video quality in Udemy Video Player. Click the gear icon on the bottom-right corner of the player, and select resolutions of 360p, 480p, 720p and 1080p for the video quality.
Ensure annotation processing is turned on in Intellij. To do so:
- In IntelliJ, select File->Settings.
- In the Settings dialog box that appears, expand the Build, Execution, Deployment node.
- On the right pane of the Settings dialog box, ensure Enable annotation processing check box is checked.
This error is reported by newer Windows version of Maven.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.3.2:perform (default-cli) on project sfg-pet-clinic: Failed to invoke Maven build. Error configuring command-line. Reason: Maven executable not found at: C:\maven\bin\mvn.bat -> [Help 1]
Cause: maven-release-plugin tries to find the mvn.bat file, while newer versions of Windows Maven comes with only mvn.cmd.
Solution: Create a copy of the mvn.cmd file in MAVEN_PATH/bin directory and rename it to mvn.bat.
Set the log level of Spring Web MVC to debug, like this.
logging.level.org.springframework.web=debug
Spring Boot starter web comes with Logback as the logging framework, and this configuration instructs Logback to emit debug messages to the console by default.
In your parent pom.xml, explicitly specify the main class as a property, like this
<start-class>guru.springframework.sfgpetclinic.SfgPetClinicApplication</start-class>
The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured
This happens when some other process is using the default Tomcat port 8080. Stop the process using port 8080. Alternatively, start your application on a different port, say 8090 by adding this property to the application.properties file.
server.port:8090
Add the following configuration to the maven-release-plugin the main pom.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<checkModificationExcludes>
<checkModificationExclude>pom.xml</checkModificationExclude>
</checkModificationExcludes>
</configuration>
</plugin>
Error:
java.lang.IllegalStateException: Cannot find template location: class path resource [templates/] (please add some templates or check your Thymeleaf configuration)
Solution:
Spring is unable to find the templates directory. Spring Boot by default looks in resources\templates
. Verify you have this directory created.