Questions tagged [spring-boot]

21171 questions
1

votes
2

answer
3k

Views

Spring Boot, static resources and mime type configuration

I'm facing a Spring Boot configuration issue I can't deal with... I'm trying to build an HelloWorld example for HbbTV with Spring Boot, so I need to serve my 'index.html' page with mime-type='application/vnd.hbbtv.xhtml+xml' my index.html will be accessed as a static page, for instance http://myserv...
Cheloute
0

votes
1

answer
18

Views

How to get command Line arguments in spring boot?

@SpringBootApplication public class CommandLinetoolApplication { @Value('${person.name}') private String name; public static void main(String... argv) { SpringApplication.run(CommandLinetoolApplication.class, argv); } } I am using eclipse so setting run configuration as -Dspring-boot.run.arguments...
Dhanraj
0

votes
0

answer
9

Views

Swagger-UI emplyeed in nginx by bunled jar, it shows blank page

Swagger-ui can visit on 'dev' environment, But it fail when I deploy it in cloud. I tried AddResoucesHandler, but it is not working. error message: GET https://user.throw.atatakai.cn/webjars/springfox-swagger-ui/springfox.css?v=2.9.2 net::ERR_ABORTED 404 (Not Found) swagger-ui.html:8 GET https://u...
Emwing
1

votes
1

answer
2k

Views

Unable find Entity .. while trying to save data

I'm getting this exception when I try to save a topic with a message: nested exception is javax.persistence.EntityNotFoundException: Unable to find mypackage.model.Message with id fb8d39ea-0094-410d-975a-ea4495781422 Here is the model : @Entity public class Topic { @Id private String id; private St...
FakeLion
1

votes
1

answer
550

Views

Right Alignment of numerical value in PDF using Apache PDFBox library

My Spring boot Java application is using apache pdf box library {version 2.0.6} for generating pdf. I want decimal values to be right aligned. It means all decimal dot should align in same vertical line. I also attached screenShot. stream.beginText(); stream.newLineAtOffset(xCordinate, yCordinate);...
1

votes
2

answer
985

Views

Spring Boot app crashes by unknown reasons

I packed my Spring Boot application into jar like others same applications that works correctly. It's almost same apps. But this app failed with errors: 2018-01-28 23:43:57.661 DEBUG 14109 --- [ main] o.s.w.c.s.StandardServletEnvironment : Adding PropertySource 'servletConfigInitParams...
Шах
1

votes
1

answer
684

Views

How to use postgis type Geography with spring-boot and postgresql?

I have a Spring-boot project with hibernate. Also, I have a postgresql database with postgis extension. I really want to make use of the postgis extension geography type. Unfortunately, it seems that Hibernate does not support the geography type, only type geometry, which is unsufficient for my need...
Ville Miekk-oja
1

votes
1

answer
2.2k

Views

Reactive Spring Query Parameters

My Spring Reactive Web API should be able to filter based on query parameters but I'm struggling to get this right. GET /v1/address?type=business Should return all addresses of type 'business' in the system (just an example since I'm not posting the actual requirements). If the parameter is absent t...
Anthony Ikeda
1

votes
1

answer
220

Views

How @scheduled annotation works in Spring Boot

I have an Spring Boot application in which I have a class with two methods likes below. @Component public class ClassA { @Scheduled(fixedDelay = 900000) public void methodA(){ //do task 'A' } @Scheduled(fixedDelay = 600000) public void methodB(){ //do task 'B' } } As per my understanding methodA sho...
GD_Java
1

votes
1

answer
3.9k

Views

Implementing Google Calendar API with Angular 5

I'm trying to connect to the Google Calendar API using Angular 5 so that I can display upcoming events on the web application I am building. I'm new in Angular and i'm looking for a way to integrate the API in my app. I searched alot but i didn't find a way to do it.
Eve
1

votes
1

answer
453

Views

Unable to use @Value annotation in Spring Boot [duplicate]

This question already has an answer here: How to access a value defined in the application.properties file in Spring Boot 6 answers I have a class @Component @Configuration public class EmailSender { private Properties properties; @Value('#{mail.smtp.starttls.enable}') private String startTls; @Val...
NickJ
1

votes
1

answer
681

Views

How to log MDC with Spring Sleuth 2.0?

referring to quesition/answer in How to log MDC with Spring Sleuth? I think this has/will change(d) with spring-cloud 2.0 as there is no SpanLogger or Slf4jSpanLogger anymore (or I don't find it) Wouldn't it be nice if application properties spring.sleuth.baggage-keys and spring.sleuth.propagation-k...
Dirk Hoffmann
1

votes
1

answer
684

Views

Test Spring Data Repository in a project without a Spring Boot Application main class

I have a small project that does not contain a class to run a Spring Boot Application. In that class I only have some configuration and some repositories. I would like to test those repositories inside the small project. For that, I have the following: @SpringBootTest @DataJpaTest public class TaskR...
Manuelarte
1

votes
0

answer
13

Views

Spring Boot 2 - Session Issues

My security config reads like this: protected void configure(HttpSecurity http) throws Exception { http .antMatcher('/**') .authorizeRequests() .antMatchers('/*.js', '/*.ico', '/*.png', '/*.css').permitAll() .anyRequest().authenticated() .and() .formLogin() .loginPage('/login') .loginProcessingUrl('...
Magd Kudama
0

votes
0

answer
4

Views

Oauth good way to login hybrid/native app?

I'm working in an hybrid app for mobile and I have a problem about how I can do the login. I have read a lot about oauth2, spring security and jwt and I builded a spring-boot project to try that. I used in that project oauth2 with password grant-type, where the user type password,username,clientid a...
cloudmanSoldier
1

votes
0

answer
10

Views

Can I somehow run multiple web modules that share the same library module with one SpringBootApplication?

I'm starting a Spring project that should be consisted of four main modules: Core module - has service and repository layer (should represent a common library for other modules) Admin module - should contain its own security configuration and endpoints (Controllers) Customer module - should contain...
K. Stef
1

votes
3

answer
185

Views

How to insert 780k records Spring Data Postgres

CSV file will be uploaded in Amazon S3 bucket. Current Implementation: Reading CSV file using OpenCSV utility's readAll which returns List Map every column value to an entity object Create a List object (Current Size :: 15000) Invoke Spring Data CRUD Repository saveAll(List objects) Out of 780k reco...
Phaneendra
1

votes
1

answer
1.8k

Views

javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:name=dataSource,type=HikariDataSource

How can i solve this problem? Which is best choice and how to do that set unique poolName destroy previous connection pool enter image description here org.apache.catalina.core.ApplicationContext.log Initializing Spring embedded WebApplicationContext 11-Aug-2018 16:05:53.863 SEVERE [Catalina-sta...
1

votes
3

answer
794

Views

SpringBoot Redis remote host

I'm making an application that uses Spring Boot, MySQL and Redis on the Back End and Angular on the Front End. I want to deploy it to Heroku so I could use my front end with it but I just can't seem to configure the remote URL for Redis. I have the Redis To Go Add-on on Heroku for this with the remo...
Sarthak Sachdeva
1

votes
1

answer
164

Views

Jackson XML to Pojo - Array without wrapper

I have a list of tags with same attributes but doesn't have a wrapper element to make it as a arraylist.. how can I hold this as an arraylist in Java Spring-boot application?
sbhatt
1

votes
2

answer
442

Views

Spring boot does not start in Tomcat instance

I have a small web application that only contains some scheduled task. When I deploy this app on a Tomcat instance nothing happens. No logs are generated, scheduling does not work. The only log I found of the application is: 31-Aug-2018 11:05:06.120 INFO [http-nio-80-exec-107] org.apache.catalina.co...
JimmyD
1

votes
1

answer
154

Views

Where and how to enable CORS on a Spring-Boot based WAR running on Tomcat?

I am running tomcat 9 on my VM and deploying Spring-Boot based WAR files built using gradle on it. I keep getting CORS errors for the APIs running there. I tried enabling the @CrossOrigin on Spring-boot but the error didn't seem to go away so I changed the web.xml file on my tomcat but still the COR...
Nithin
1

votes
3

answer
976

Views

How to release all cached data after a function call in Spring Boot

I am using Spring Boot 2.0.4.RELEASE version with Cache Enabled with default cache provider only No external Cache provider is used. I have scheduled a batch which run at a specific time everyday. During its run certain method calls which involves Data Access are cached and it works fine. Now I want...
Nitish Kumar
1

votes
5

answer
714

Views

How to get current user in every request in Spring Boot?

I would like to get the username of the user in every request to add them to log file. This is my solution: First, I created a LoggedUser with a static property: public class LoggedUser { private static final ThreadLocal userHolder = new ThreadLocal(); public static void logIn(String user) { userHo...
TranNgocKhoa
1

votes
2

answer
294

Views

Including spring boot endpoint path variable as a metric dimension

I have api endpoint : /user/{tenant}/create I am using spring boot 2 with micrometer for metrics. By default @Timer annotation for spring boot 2 endpoint includes the following tags: exception,method, uri, status I want to add the passed value for api parameter 'tenant' as an extra tag for the endpo...
Rohan Shetty
1

votes
1

answer
2.5k

Views

SpringBoot 2 the elements were left unbound

i have a file application.yml with my Spring Boot application which is not willing to run. According to logs the reason of The elements [simulator.geo.b12,simulator.geo.b13,simulator.geo.b21,simulator.geo.c6,simulator.geo.host] were left unbound. This property however is set in application.yml and...
runbird
1

votes
2

answer
46

Views

Spring - Validate the field of a field

I am developing an API with Spring boot in which I have an object which has another object which has a field that I need to validate. These are the following: CodigoDTO public final class CodigoDTO { private String codigo; @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private String accion;...
Wrong
1

votes
1

answer
576

Views

Spring boot 2.0.3.RELEASE, Spring data rest, application error, failed to start

Unable to start spring boot application. Repository and its associated domain import com.vircosolutions.mobileapi.domain.Awards; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.rest.core.annotation.RepositoryRestResource; @RepositoryRestResource(exported...
Rana Rashid
1

votes
1

answer
435

Views

Does Spring Security OAuth2 support Authorization Code Flow with PKCE for browser (Angular) clients?

Browser applications auth used to be managed using the Implicit grant of the Authorization Server. I successfully implemented this using Spring Security Oauth. This approach has several drawbacks: Refresh tokens are not supported, so when the token expires we need to reauthenticate with the Authoriz...
codependent
1

votes
1

answer
243

Views

-bash: ./deploy.sh: Permission denied , ERROR: script returned exit code 126

I am trying to implement continuous deployment using Jenkins and that involves sending a jar file to a remote server and start the jar once its on the remote server. The problem is that i keep getting access denied error and i have tried every account i have on my remote and local server nothing se...
Erent
1

votes
3

answer
445

Views

keyHolder.getKey() return null

Why code from 'Spring in action 5' don't work (keyHolder.getKey() return null, but entity is saved in DB)? private long savePizzaInfo(Pizza pizza) { pizza.setCreatedAt(new Date()); PreparedStatementCreator psc = new PreparedStatementCreatorFactory( 'insert into PIZZA (name, createdAt) values (?, ?)'...
lobs
1

votes
1

answer
1.2k

Views

Spring Boot Upgrade Error - Invalid bean definition with name org.springframework.transaction.config.internalTransactionalEventListenerFactory

In an attempt to upgrade spring boot to the latest version 2.1.1 & spring framework to 5.1.3 in a java based web application, I get the following error Invalid bean definition with name 'org.springframework.transaction.config.internalTransactionalEventListenerFactory' defined in null The complete st...
Andy Dufresne
1

votes
1

answer
172

Views

Connect JMS queue using JNDI with Spring Boot

I had a hard time figuring out how to implement a Spring Boot JMS Listener, listening to an ActiveMQ queue within a JBoss application server. Therefore I choose to post a question and answer it with my final solution, hoping it could save some of you a few hours.
Thomas Joeisseint
1

votes
1

answer
53

Views

Spring boot: error asking to implement all methods in JpaRepository

Why is this happening? It didn't happen when I worked on a spring project in STS few months back. I have imported the following in the class: import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; Following is my pom.xml: 4.0.0 org.springframe...
S.K.
1

votes
1

answer
196

Views

Spring Cloud Stream @SendTo Annotation not working

I'm using Spring Cloud Stream with Spring Boot. My application is very simple: ExampleService.class: @EnableBinding(Processor1.class) @Service public class ExampleService { @StreamListener(Processor1.INPUT) @SendTo(Processor1.OUTPUT) public String dequeue(String message){ System.out.println('New mes...
italktothewind
1

votes
1

answer
110

Views

Create jar with fix name excluding version using gradle

I want to create a fat jar using gradle only with name, not include a version of the project. I am using gradle 5.1 and spring boot 2.1.1. I have tried the following solutions with no luck https://stackoverflow.com/a/53123771/8123983 https://stackoverflow.com/a/31407245/8123983 Default jar name proj...
S_K
1

votes
1

answer
78

Views

Which graphql-spring-boot-starter should I choose?

I'm thinking about adding GraphQL functionalities to my Spring Boot application. I found there are two artifacts for that. One is com.graphql-java-kickstart:graphql-spring-boot-starter and the other is com.graphql-java:graphql-spring-boot-starter. Which one should I choose?
Jin Kwon
1

votes
5

answer
160

Views

Spring Boot + JPA : @Transactional annotation : Roll back is not working

I am using @Transactional with spring boot and jpa. But it is not working. Can somebody help out. My inserts are in myDAO which is autowired in service class. Below code is method of service class which is implementing service interface class MyService implements Service { @Transactional(rollbackFor...
Naveen Yalla
0

votes
0

answer
10

Views

Non Blocking IO with Spring Boot 2

I am trying to wrap my head around non-blocking io for making http requests from a Spring Boot 2 application. My use case is such that I need to make a service-to-service HTTP calls without dedicating a thread to every single outgoing HTTP call. Would appreciate if someone could point me to the rig...
Karthick
1

votes
3

answer
223

Views

Spring default consumes and produces

I'm writing a servlet that will use a bunch of RestControllers to provide functionality. All of that will use JSON almost exclusively, so I would like a compact way to say: Unless specified otherwise, consume and produce MediaType.APPLICATION_JSON_VALUE for everything. I thought I found a nice solut...
Senshi

View additional questions