Posts

Showing posts with the label spring-boot

how to construct @service in Springboots using a payload variable

how to construct @service in Springboots using a payload variable I'm quite new in spring boots so I hope this is not a silly question I have a @Service that needs to initiate a class attribute, this attribute needs a information that comes from the RestPayload in the Controller. I'm not finding the most recommend way to do that. @RestController public class UserController { @Autowired private UserService userService; @RequestMapping("/searchUser") public List<UserWrapper> searchUser(@RequestBody UserWrapper userWrapper) { List<UserWrapper> returnUserWrapper = userService.findByName(userWrapper); return returnUserWrapper; } } And the service layer, I would like to be something like: @Service public class UserService { private LdapTemplate ldapTemplate; public static final String BASE_DN = "xxxxxxx"; @Value( value = "${sample.ldap.url}" ) private Str...

how to make common dead letter exchange to all my queues

how to make common dead letter exchange to all my queues I have a common library that handles all the configuration for the rabbitMQ and I'm aiming to achieve a common strategy to handle errors messages after certain attempts and what is in my mind have an exchange that receives all dead letter messages and will differentiate each message by having a header that has an originated queue name. this all after a number of attempts and retries. I have no idea how to implement this approach, your help to achieve this! here one of my lisnteners @RabbitListener(bindings = @QueueBinding( value = @Queue(value = "${swift.queue.driverOnlineStatus}", durable = "true"), exchange = @Exchange(value = "${swift.queue.driverExchange}", type = ExchangeTypes.HEADERS, ignoreDeclarationExceptions = "true"), arguments = { @Argument(name = "x-match", value = "all"), @Argum...

Springboot SOAP service unmarshalling Issue with the response from WebServiceTemplate

Springboot SOAP service unmarshalling Issue with the response from WebServiceTemplate I am really bugged with an unmarshalling issue with the response from the SOAP service. I am using springboot application and WebServiceTemplate for calling an existing SOAP service. I am using below code to set up beans for marshalling and webservicetemplate. Any help is highly appreciated. On calling webServiceTemplate.marshalSendAndReceive(request); I am expecting TravelResponse object but it is giving me JAXBElement<TravelResponse> object as response. I need help to understand 1) why is it giving above response instead of TravelResponse 2) How to convert to TravelResponse webServiceTemplate.marshalSendAndReceive(request); TravelResponse object JAXBElement<TravelResponse> object TravelResponse TravelResponse Code snippet below: @Bean Jaxb2Marshaller jaxb2Marshaller() { Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller(); jaxb2Marshaller.setContextPath("com.cater.t...

spring error No qualifying bean of type JdbcTemplate

spring error No qualifying bean of type JdbcTemplate I have a spring boot application where I am creating Datasource and JdbcTemplate manually in my config because I need to decrypt datasource password. Datasource JdbcTemplate I am using tomcat DataSource ( org.apache.tomcat.jdbc.pool.DataSource ) as recommended in spring boot docs since I am configuring connection properties. DataSource org.apache.tomcat.jdbc.pool.DataSource I am excluding autoconfiguration for datasource (see Application.java ) since I am creating one manually. Application.java Application.java // exclude datasourceAutoConfiguration since we are creating manaully creating datasource bean in AppConfig @SpringBootApplication @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}) public class Application { public static void main(String args) { SpringApplication.run(Application.class, args); } } Here is my application.properties file application.properties jdbc.hostdb.url=jdbc:jtds:sq...

Spring Boot 2.0.0 & static resources with different domains for the same app

Spring Boot 2.0.0 & static resources with different domains for the same app I have migrated a web app from Spring Boot 1.5.10 to 2.0.0, which serves content trough different domains and it is deployed with Heroku. The main domain works fine, but with the other ones the static elements like Javascript, CSS, images and icons don't work and the browser arises this error: Refused to execute script from '' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled The static resources are located at: /resources/static/css /resources/static/css /resources/static/js /resources/static/js /resources/static/images /resources/static/images All domains are secured with a Let's Encrypt SSL certificate, provided by Heroku. The domains are all redirected, including the main one, with a CNAME to the address provided by Heroku. The main domain has access to all the content, and the secondary ones just can access to the content inside a d...

Spring boot jpa and ms sql update issues

Spring boot jpa and ms sql update issues I’m working on a REST web service and I want to migrate from “postgres” database and PHP (the existing web service), to microsoft sql server 2012 and spring boot. So, I have generated entities using Netbeans IDE from the existing “postgres” database. Here’s an example of a generated entity: @Entity @Table(schema = "dbo") @XmlRootElement @NamedQueries({ @NamedQuery(name = "Activite.findAll", query = "SELECT a FROM Activite a"), @NamedQuery(name = "Activite.findById", query = "SELECT a FROM Activite a WHERE a.id = :id"), @NamedQuery(name = "Activite.findByLabel", query = "SELECT a FROM Activite a WHERE a.label = :label"), @NamedQuery(name = "Activite.findByType", query = "SELECT a FROM Activite a WHERE a.type = :type"), @NamedQuery(name = "Activite.findByDateOperation", query = "SELECT a...

Mysql unable to import csv files

Mysql unable to import csv files I want to clarify that i browse similar questions about file encoding and importing csv files to Mysql. None of these worked for me. The situation is like this: i was in charge of the task of creating a spring boot application which generates csv files filled with random data to populate a database (each csv file correspond to a table in the DB). the first scenario was to import these .csv files into Oracle 12c. There was no problem, i done it, there was no errors in the data. The actual problem is using the same .csv files to import them into Mysql, it is not possible. Clarifying both Databases (Oracle and Mysql) have both the same tables with the equivalent Data Types I tried: Exporting the data from Oracle (from SQLDeveloper) into a .csv file and then import it in Mysql, i got the same error below. the Data Table Import Wizard from Mysql-workbench and it says: Can't analyze file, please try to change encoding type, if that doesn't help, mayb...