JHipster - Run spring boot with mvnw command - java

I am using a JHipster to create a spring boot application with PostgreSQL.
Actualy, when i execute the command mvnw the application-dev config file is "cleaned" to the initial properties.
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:postgresql://localhost:5432/test
username: test
password:
In this case, my database properties (user, password ...) are cleaned. I obtain the error:
"2017-08-06 18:17:10.726 ERROR 10844 --- [ restartedMain]
com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception
during pool initialization.
org.postgresql.util.PSQLException: The server requested password-based
authentication, but no password was provided."
Anyone can help me?

Need to put password into password .
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:postgresql://localhost:5432/test
username: test
password:<YOUR PASSWORD>

Related

How to integrate Ping Identity SAML with Spring-Boot?

I am trying to integrate spring boot with ping identity. I am getting below error while hitting base-URL
ErrorCode: INVALID_ISSUER - Unable to find application for spEntityId:
'http://localhost:8080/sample-sp/saml2/service-provider-metadata/samlexample'
in environment 839268e3-5ccc-4d92-8556-211a062a122b
application.yml
server:
port: 8080
servlet:
context-path: /sample-sp
logging:
level:
root: DEBUG
org.springframework.web: INFO
org.springframework.security: INFO
org.springframework.security.saml: INFO
org.opensaml.xmlsec: TRACE
spring:
security:
saml2:
relyingparty:
registration:
samlexample:
signing:
credentials:
- private-key-location: "classpath:credentials/private.key"
certificate-location: "classpath:credentials/public.cer"
identityprovider:
singlesignon:
sign-request: false
entity-id: demo-saml-eid
sso-url: https://auth.pingone.asia/839268e3-5ccc-4d92-8556-211a062a122b/saml20/idp/sso
metadata-uri: https://auth.pingone.asia/839268e3-5ccc-4d92-8556-211a062a122b/saml20/metadata/fccace63-397d-43c3-b6bf-605cba6224ba
# verification.credentials:
# - certificate-location: "classpath:credentials/identity-provider-certificate.crt"
Issuer ID
https://auth.pingone.asia/839268e3-5ccc-4d92-8556-211a062a122b
Single Logout Service
https://auth.pingone.asia/839268e3-5ccc-4d92-8556-211a062a122b/saml20/idp/slo
Single Signon Service
https://auth.pingone.asia/839268e3-5ccc-4d92-8556-211a062a122b/saml20/idp/sso
IDP Metadata URL
https://auth.pingone.asia/839268e3-5ccc-4d92-8556-211a062a122b/saml20/metadata/fccace63-397d-43c3-b6bf-605cba6224ba
Initiate Single Sign-On URL
https://auth.pingone.asia/839268e3-5ccc-4d92-8556-211a062a122b/saml20/idp/startsso?spEntityId=demo-saml-eid

Spring, H2, R2DBC and Liquibase: /.testdb.trace.db: Read-only file system

When trying to start a Spring Boot application for tests (with H2 database) with R2DBC and Liquibase configured, I get the following error:
2022-10-04 12:50:18.893 INFO 57774 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 67 ms. Found 2 R2DBC repository interfaces.
org.h2.message.DbException: Log file error: "/.testdb.trace.db", cause: "java.nio.file.FileSystemException: /.testdb.trace.db: Read-only file system" [90034-214]
Here's my config:
spring:
liquibase:
change-log: classpath:liquibase/db.changelog.xml
contexts: production
url: jdbc:h2:file:///./.testdb;MODE=MySQL
r2dbc:
url: r2dbc:h2:file:///./.testdb
h2:
console:
enabled: false
Is there anything I can do to fix that error?
The problem was caused by the URL, R2DBC requires it to look like this:
r2dbc:
url: r2dbc:h2:file:///./.testdb
But then if you try to copy it over to Liquibase part, the error appears. To fix that, remove forward slashes from Liquibase URL:
spring:
liquibase:
change-log: classpath:liquibase/db.changelog.xml
contexts: production
url: jdbc:h2:file:./.testdb;MODE=MySQL
Final version:
spring:
liquibase:
change-log: classpath:liquibase/db.changelog.xml
contexts: production
url: jdbc:h2:file:./.testdb;MODE=MySQL
r2dbc:
url: r2dbc:h2:file:///./.testdb
h2:
console:
enabled: false

Spring boot profile not picking the properties file

I have application-database.yml, application-sql.yml.Tried running using -Dspring.profiles.active=local but properties data not picking up. How to run this?
application-local.yml
spring:
profiles:
group:
local: database, sql, message
application:
name: HP-FETCHER-CONFIG-SERVICE
by Dspring.profiles.active=local you are telling spring that you use local profile, use Dspring.profiles.active=database instead
I'm not sure if this applies to your project:
just use application.yml,then:
spring:
profiles:
active: local, database, sql
---
spring:
profiles: local1
...
...
---
spring:
profiles: local
...
...
---
spring:
profiles: sql
...
...
---
spring:
profiles: database
...
...
when start without -Dspring.profiles.active it will use the local, database, sql. if start with -Dspring.profiles.active=local1,database,sql it will use the local1, database, sql
If you want to use group you have to specify it in either application.yml or application.properties file. The corresponding blog post says:
To define a group, you can use the spring.profiles.group property in your application.properties or application.yml file.
For me this seems to be working as expected. I have the below application.yml file
spring:
profiles:
group:
super-1-2: profile-1, profile-2
super-2-3: profile-2, profile-3
---
spring:
config:
activate:
on-profile:
- profile-1
---
spring:
config:
activate:
on-profile:
- profile-2
---
spring:
config:
activate:
on-profile:
- profile-3
If I run my application with profile super-1-2 activated, I get a confirmation in my logs that all three super-1-2, profile-1 and profile-2 are active.
2022-08-31 16:52:27.109 INFO 67935 --- [ restartedMain] c.s.n.SampleApplication : The following 3 profiles are active: "super-1-2", "profile-1", "profile-2"
On the other hand, if I run my application with profile super-2-3 activated, I get a confirmation in my logs that all three super-2-3, profile-2, and profile-3 are active.
2022-08-31 16:52:41.117 INFO 68090 --- [ restartedMain] c.s.n.SampleApplication : The following 3 profiles are active: "super-2-3", "profile-2", "profile-3"

Issue in Running Jar file of Spring boot Gradle

I am not able to run the jar file of Spring Boot Gradle which I had created with ./gradlew clean bootJar jacocoMergeAll
and when I run in intellij with run button, I am able to run it.
and below is my commands which I had ran with intellij VM options which ran successfully but with jar this command does not work when I run the Jar file.
Below vm option is working one
-Dspring.profiles.active=local -Dserver.port=8080 -Dajp.port=0 -Dspring.datasource.url=jdbc:oracle:thin:#localhost:1521:OraDoc -Dspring.datasource.username=system -Dspring.datasource.password=MyPasswd123 -Dspring.config.additional-location=file:/Users/myUser/codebase/config/ -Dlogging.config=file:/Users/myUser/codebase/config/logback-spring.xml
Below running jar is not Working
java -Dspring.profiles.active=local -jar demo-0.1.0-SNAPSHOT.jar -Dserver.port=8080 -Dajp.port=0 -Dspring.datasource.url=jdbc:oracle:thin:#localhost:1521:OraDoc -Dspring.datasource.username=system -Dspring.datasource.password=MyPasswd123 -Dspring.config.additional-location=file:/Users/myUser/codebase/config/ -Dlogging.config=file:/Users/myUser/codebase/config/logback-spring.xml
I have tried with both -Dspring.datasource.url=jdbc:oracle:thin:#localhost:1521:OraDoc and -Dspring.datasource.url=jdbc:oracle:thin:#localhost:1521/OraDoc but none of this worked
when I run above jar command I get below error of not find the url
***************************
APPLICATION FAILED TO START
***************************
Description:
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
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (the profiles local are currently active).
my config file are under this directoy:
/Users/myUser/codebase/config/application.yml
/Users/myUser/codebase/config/application-local.yml
content of application.yml
server:
tomcat:
connectionTimeout: 300000
management:
endpoint:
mappings:
enabled: true
spring:
liquibase:
change-log: classpath:/db/changelog/db.changelog-master.xml
datasource:
driver-class-name: oracle.jdbc.driver.OracleDriver
hikari:
minimum-idle: 5
maximumPoolSize: 20
idleTimeout: 30000
maxLifetime: 2000000
connectionTimeout: 30000
poolName: factory-data-pool
jpa:
hibernate:
use-new-id-generator-mappings: false
ddl-auto: none
database-platform: org.hibernate.dialect.Oracle12cDialect
content of application-local.yml
server:
port: 8080
spring:
datasource:
url: jdbc:oracle:thin:#localhost:1521:OraDoc
username: system
password: MyPasswd123
liquibase:
contexts: local
Can someone please guide me on what wrong I am doing here?

Failed to bind properties under '' to com.zaxxer.hikari

I'm doing Spring Security and I'm trying to connecte my API with database to get user Authentication.
I don't know the error.
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:
Property: driverclassname
Value: com.mysql.cj.jdbc.Driver
Origin: "driverClassName" from property source "source"
Reason: com.mysql.cj.jdbc.Driver
Action:
Update your application's configuration
Process finished with exit code 1
It looks like HikariCP configuration issue. If you are using yml file for spring boot, the application.yml file should have the following contents.
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: <jdbc url specific to your database>
driver-class-name: <database url>
username: <username>
password: <password>
hikari:
idle-timeout: 10000
Please change the place holders as I have mention with angles <> as per the database.

Categories