Spring Boot app starts on Windows 10 but not on OS X (HS) - windows

I have a Spring Boot application that connects to a postgresql-database. I am working on it on windows 10 (work) and macos (home). The code is shared via github. On win10 the app starts without any problems but when I update the code on macos and restart the app I often get the error Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class
The one way I can remedy the issue is to include the H2 in-memory-db in pom.xml, start the app, remove it again and restart the Spring Boot app. But it doesn't always work.
My application.properties file:
spring.datasource.url=jdbc:postgresql://localhost:5432/john
spring.datasource.username=doe
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
I am using Java JDK 10 in both environments with the Spring Tools suite in eclipse.
I have cleaned the project, updated maven right-clicking on the project -> Maven -> Update Project but without luck.

Related

Which profile does Intellij use when you do Run Application?

I have two maven profiles.One is Dev which has a dependency on embedded Tomcat
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
and Prod which has not.
At the upper right corner of Intellij I can see the two profiles.
When I Run Application having checked the Dev profile, the app fails because it can't find the embedded Tomcat.
If I include the dependncy in the main profile and removing the scope tag,the app loads.
What am I doing wrong?
when you do Run Application from within Intellij under which profile does it run the application?
The provided scope means that this dependency is supposed to be provided by the external environment that runs your application, e.g. the application server, in case you deploy it as a war file. In your case, when you run it in the development environment, there is noone to provide this dependency, so specifying this scope probably doesn't make sense. This is the reason it works when you remove the scope element.

Invalid web-app-versionType after Spring Upgrade

To support JUnit 5, I recently upgraded a Spring Boot application to version 2.4.7.
Local development uses an embedded Tomcat server, while all other environments run on a Weblogic server 12.1.3.
Everything runs locally, but using the Weblogic Server results in the following exception:
Caused By: weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND
/weblogic.utils.classloaders.GenericClassLoader#700d06bb finder: weblogic.utils.classloaders.CodeGenClassFinder#40ce7cdd annotation: APP#/WEB-INF/lib/tomcat-embed-websocket-9.0.46.jar!/META-INF/web-fragment.xml:18:3:18:3: problem: cvc-enumeration-valid: string value '4.0' is not a valid enumeration value for web-app-versionType in namespace http://xmlns.jcp.org/xml/ns/javaee
at weblogic.descriptor.internal.MarshallerFactory$1.evaluateResults(MarshallerFactory.java:249)
Other questions on the topic led me to check web.xml, but it contains version="3.0".
I don't know how to proceed because I don't understand where this comes from.
Do you have this in your pom.xml to exclude packaging of the tomcat jar files when creating the war file?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
The spring-boot-starter-tomcat dependencies must have provided scope.

intelij spring boot hot swap causes context reload

I am using Intellij 2017.2 with Spring Boot 1.5.4
When I recompile my current class with ctr+shift+F9, instead of the IDE doing a bytecode hotswap, the spring container gets reloaded.
On top of that, after the reload my RestConroller no longer works
I have tried adding / removing from my pom
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
please advise
I am not sure if this is a spring boot bug as of the new version, but I ended up disabling manually the hot reload via properties:
This is done by setting the following in your application.properties:
spring.devtools.restart.enabled=false
The official doc:
https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-devtools.html#using-boot-devtools-restart-disable

Connecting ONOS web application with MariaDB . ClassNotFoundException

I am trying to make a custom web application on top of ONOS and I am having a difficulty to connect my application to the MariaDB server located on my localhost. What I've done is applying MariaDB dependencies to the POM.xml file of my application.I am using IntelliJ Idea Community version and I have less knowledge in developing Java web application.
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.1.0</version>
<scope>compile</scope>
</dependency>
Your help is much appreciated.

No suitable driver found for jdbc (only in jar file)

I'm using netbeans to create a simple java maven application with a very simple JavaDB database connectivity. I've configured the dependencies in maven pom.xml file as follows, and my application works correctly when I run it from the IDE.
pom.xml
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.12.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.12.1.1</version>
</dependency>
Yet when I build the project with dependencies and try to run the final jar, I get the following error.
java.sql.SQLException: No suitable driver found for jdbc:derby://localhost:1527/TestDB
I've even tried copying the derby.jar to the application jar file location. But still the above error appears. I'm not sure what I'm doing wrong.

Resources