Questions tagged [spring]

90126 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
2

answer
21

Views

JPA: How to map only one property from another entity

Let's say I have two entities: @Entity public class Phone { @Id private Long id; private String number; } @Entity public class Person { @Id private Long id; private String name; } The relationship between a person and a phone is one to one. How could I access only the phone's number in the Person en...
Fabian Mendez
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
0

votes
1

answer
11

Views

How does Spring Kafka/Spring Cloud Stream guarantee the transactionality / atomicity involving a Database and Kafka?

Spring Kafka, and thus Spring Cloud Stream, allow us to create transactional Producers and Processors. We can see that functionality in action in one of the sample projects: https://github.com/spring-cloud/spring-cloud-stream-samples/tree/master/transaction-kafka-samples: @Transactional @StreamListe...
codependent
1

votes
0

answer
6

Views

Different handling of basic authentication in rest client and web app in browser

I have angular frontend and spring backend. I'm using spring security to hande http basic authentication. I noticed strange difference in behaviour using advanced rest client(or any other) and angular web app. For tests I disabled my httpInterceptor so it is not including 'Authorisation: Basic fooba...
skoomi
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
2

answer
2.3k

Views

JMS Sessions, “transacted” and “auto-acknowledge”

What does JMS session exactly mean? What does it mean that a JMS session can be or not 'transacted'? What does it mean that a JMS session can be or not with 'auto-acknowledge'?
Johan
1

votes
2

answer
1.9k

Views

Return immediately in spring web flux

I am trying to create framework which should return 201 response. When a request is made to an API then i want to send back response immediately and process the request in background. Flux.fromIterable(request.getApiRequests()).log().flatMap(item -> { WebClient.RequestHeadersSpec apiCallSpec = WebCl...
Lokesha S
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
2

answer
423

Views

Spring read property file outside the class path

I have a property file located in tomcat folder.Im trying to read the propert file content as follow.but im getting null value for the property value. file path has no any issue. @ComponentScan(basePackages = 'org.sakaiproject.log.api') @Configuration @PropertySource(name = 'props', value = { 'file:...
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
1

answer
926

Views

Spring kafka and Kafka Cluster

I've configured 3 kafka's in cluster and I'm trying to use with spring-kafka. But After I kill the kafka leader I'm not able to send other messages to queue. I'm setting the spring.kafka.bootstrap-servers property as: 'kafka-1:9092;kafka-2:9093,kafka-3:9094' and all of names in my hosts file. Kafka...
0

votes
0

answer
13

Views

Hibernate Could not fetch the SequenceInformation from the database but still works fine

I have 2 entities User And UserRole. if I make UserRole entities like this with a role as id everything works fine but this is bad because I can't have 2 different users with the same role: @Entity @Table(name = 'USER_ROLES', uniqueConstraints = @UniqueConstraint( columnNames = { 'ROLE', 'USERNAME'...
Patches Joe
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
873

Views

Visual Studio Code - Java - Lombok - The method is undefined for the type

I downloaded the following project and imported it into Visual Studio Code: https://github.com/oktadeveloper/okta-spring-boot-2-angular-5-example I have a problem on the following class, when invoking: car.getName(). https://github.com/oktadeveloper/okta-spring-boot-2-angular-5-example/blob/d5c95916...
davidesp
1

votes
2

answer
126

Views

what are the best approaches (practices) to create stateful microservices?

I need to create a food ordering service, using microservices, scalable , cluster, several steps to order. Need to store user data between steps / requests. What is an approach to keep state and user data? Store it in DB? Cache? Shared memory? Are there any tutorials for the best practice of it? (I...
arminvanbuuren
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
196

Views

HttpHeaders getFirst() case insensitivity

I'm fetching HTTP headers with Spring's RestTemplate. HTTP headers are case insensitive, but the documentation for HttpHeaders doesn't seem to acknowledge this. A quick test shows that things are working as expected... HttpHeaders headers = restTemplate.headForHeaders(url); Long a = Long.parseLong(...
nobar
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
1

answer
413

Views

Reading POST body: java.lang.IllegalStateException: Only one connection receive subscriber allowed

In Spring Webflux, when I read a POST body, and try to work with it, it always results in the IllegalStateException from the title. Here the code: @Bean public RouterFunction selectByPost(SasoSecurityFacade solrHandler) { return RouterFunctions.route(RequestPredicates.POST('/v1/{collection}/select')...
Frischling
1

votes
1

answer
1.3k

Views

Spring Data JPA method query with paging gives me an error

I am developing with Spring Data Jpa. I have an interface extending JpaRepository, and I want to query with Query Method and paging. I want to query 'select * from cheat where vote
PLAYMAKER
1

votes
2

answer
42

Views

Should multiple Spring controllers direct to same view file?

Suppose in Controller A, I have @GetMapping('/path/1') public String getIndex() { //it's own unique logic ... return 'path/to/file'; } and in Controller B, I have @GetMapping('/path/2') public String getIndex() { //It's own unique logic ... return 'path/to/file'; } Is it a good practice to have two...
John Doe
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

View additional questions