Posts by nullptr • 3,925 points
142 posts
-
2
votes2
answers63
viewsA: How to detect when the user tries to access a URL without having a ROLE for that URL in Spring Security
You can also implement Annotation @Secured methods that depend on specific roles (controllers, services...). @Secured ({"ROLE_USER", "ROLE_ADMIN"}) public void meuMetodoSeguroPorRoles() { ... }…
-
0
votes1
answer497
viewsA: Request blocked by CORS - Vue and Spring Boot
Try performing this configuration class to adjust the CORS headers: @Configuration public class CorsConfig { @Bean public CorsConfigurationSource corsConfigurationSource() { final CorsConfiguration…
-
2
votes1
answer396
viewsA: How do I rate a test, release or Feature?
Considering the separation as below: Feature branches: Contains codes that may or may not be included in the next release, the merge of the Features is performed in the branch develop develop…
-
1
votes1
answer58
viewsA: Special Character with Scanner and Filereader
The problem is at the time of reading the file. How are you using just the Filereader, default charset will be assumed (in case your JVM should be ISO-8859-1, can be easily checked through…
-
0
votes2
answers735
viewsA: Multiple Databases with Spring Boot
If you want to create a new Datasource at runtime, you can use the Datasourcebuilder. This class provides an enormous flexibility and ease, an example of use is the following: public DataSource…
-
1
votes5
answers578
viewsA: How to validate when Resultset does not find any value?
My answer will be very similar to what I answered in this question. The method rs.next() will walk in the ResultSet, and if there is a record will return true. Recalling that the if( rs.next() )…
-
0
votes1
answer240
viewsA: No Qualifying bean of type helps with this error:
The problem is in its package hierarchy, by default Spring Boot looks below the hierarchy from where the main method is: Your main is in the package com.market.app Your controller is in the package…
-
1
votes4
answers319
viewsA: Regex - set 2 limits and pick up all content inside
Simple as that: ENERGIA ELETRICA CONSUMO.*% EDIT Removing the %: ENERGIA ELETRICA CONSUMO.*(?=%) The exclusion of delimiters can be achieved by lookaround See working here…
-
3
votes3
answers219
viewsA: Get maximum table value (JPA) with Java 8
Simply "uncouple" the content of Optional: Optional<Integer> maxId = objetoRiscoDao.findAll().stream().map(ObjetoRisco::getId).max(Integer::compare); modelAndView.addObject("maxId",…
-
0
votes1
answer101
viewsA: REST API works locally, but does not work on TOM CAT
You must follow the guidelines according to spring boot documentation 1) Leave the embedded server dependency as provided: <dependency> <groupId>org.springframework.boot</groupId>…
-
1
votes1
answer30
viewsA: How is it possible not to use a dependency to compile, but to use it at runtime?
There are dependencies that do not load all their classes into ClassLoader due to the cost of loading, and even because they can have several separate modules in several Jars. Imagine the following:…
-
0
votes1
answer66
viewsA: Primefaces p:chips, is there any way to start the list of tags with no value?
The problem is in the logic of instantiating the list with values inside: return Arrays.asList(canInteresses); // Se canInteresses for null, a lista será criada com um elemento nulo dentro I believe…
-
1
votes1
answer175
viewsA: JWT IN JAVA (SPRING BOOT)?
First you must choose a lib for JWT token generation, you can find several to choose from here. For this example I will use the jjwt, chose this version: <dependency>…
-
1
votes1
answer23
viewsA: How to find the mockite method according to the package?
Any Mockite version equal to or greater than 2.1.0 as described in release Notes: The Mockito class does not inherit from Matchers class anymore. Instead Mockito and Matchers classes Both inherit…
-
4
votes1
answer95
viewsA: What do the terms Memory Poisoning and HWPOISON mean?
Let’s go in pieces :) Why we have them? Back in 2009, Intel included in its processors a new engine called Machine Check Architecture Recovery (or commonly called MCA Recovery). This new mechanism…
-
2
votes2
answers1661
viewsA: How to sort a Map by key in Java
Using Java 8 this could be solved as follows: public static void main(String[] args) { Map<Date, Integer> map = new HashMap<>(); map.put(LocalDate.now().toDate(), 1);…
-
0
votes1
answer18
viewsQ: How to validate which transaction mode is being used? (Aspectj / Proxy)
At the moment, we are building a module in Spring Boot that uses a legacy settings, built on top of Spring MVC and has many configurations (XML and classes). After a few weeks, we were able to make…
-
1
votes1
answer106
viewsA: Problems with the JDBC connection
I believe you’re confusing the purpose of the method getRow(), removing the section of documentation: Retrieves the current row number. The first row is number 1, the second number 2, and so on.…
-
0
votes2
answers3730
viewsA: CORS: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status
As I replied in more detail in this answer for @Dup, I believe that setting the filter is unnecessary, since Spring Boot already provides resources to handle CORS. To perform the change of headers,…
-
4
votes1
answer240
viewsA: What does git stash create?
I will explain using as a basis the documentation of the git stash create: create Create a stash entry (which is a regular commit object) and return its object name, without storing it anywhere in…
-
3
votes1
answer744
viewsA: What are the dangers of keeping the Oauth2 token on the frontend?
It’s interesting you raise these two scenarios: Cookie storage, vulnerable to CSRF, and also has a giant list of options to prevent (however, using cookies is discouraged by the specification) The…
-
2
votes1
answer334
viewsA: How to create a unit test using mockite in a list of objects
In your test context, the most important thing to do is to validate whether the properties of HistoricoSituacaoEntity created within the method are in accordance with what you expect, and if the…
-
1
votes1
answer28
viewsA: JDBC mysql Macos operating system
Since the Mysql nector is a Java lib, you can use it on all platforms using the option Platform Independent in the operating system of download page. Or download from a repository using a dependency…
-
1
votes1
answer324
viewsA: java.lang.Assertionerror: Expected: not null but: was null - Junit test
You’re calling a method of indicioDAO, which is a @Mock. The standard behavior of a @Mock will always return null, it is a utility object for checks and simulation of returns, exceptions, among…
-
2
votes1
answer1505
viewsA: HV000030: No Validator could be found for Constraint 'javax.validation.constraints.Email' validating type 'java.lang.String'
How do you own the hibernate-validator in his pom.xml, change the annotation of: javax.validation.constraints.Email To: org.hibernate.validator.constraints.Email This way Hibernate will provide the…
-
3
votes2
answers4265
viewsA: Error executing . JAR "no main manifest attribute in nutriclinweb-api.jar"
You are mixing plugins to generate your JAR, you should use only the Spring Boot plugin to generate the executable. Executable JAR generation occurs through execution repackage: <plugin>…
-
1
votes1
answer49
viewsA: Doubt about the Controller in spring mvc
We will answer in parts When I fill out a form and request a controller method, all the parameters I receive within that method are in the request? Yes, form data is in the body of your request. The…
-
1
votes1
answer505
viewsA: How to create a . JAR for test automation?
I recommend you use the strategy of implementing the tests in a common module, and run a standard suite per module using @Suite: // Teste padrão - NOTE que a classe é abstrata public abstract class…
-
2
votes1
answer92
viewsA: Error starting JSF application in Apache - CDI Beanmanager instance is not available in JNDI
You probably have conflict between your project libs and server libs, this may happen for some reasons: Incompatible libs (different libs where versions "don’t talk to each other") Same lib in…
-
1
votes1
answer98
viewsA: Css only applies on one page, using Spring MVC
Instead of using the ${contextPath}, the best way to do with Spring is to use a framework resource to map the resources of the application. If you are using configuration via XML, it would be like…
-
2
votes1
answer2480
viewsA: Can you program in java by creating frame by VS code?
Yes it is possible, a Jframe is nothing more than any Java code. To run Java code in Visual Studio Code you must install this plugin. I believe it is not productive, because you have to manually…
-
0
votes2
answers250
viewsA: "algaworks" - Bigdecimal - Sum of values
You have two problems with your code: You are not returning any value in your function valorTotal Your total value calculation logic is confused, a method is calculating and changing and at the same…
-
3
votes2
answers3143
viewsA: .antMatchers(). permitAll() does not seem to work
You need to disable CSRF before authorizing requests, try this way: @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable() .authorizeRequests()…
-
4
votes1
answer930
viewsA: Jpa Hibernate does not create table in H2
You are using wrong properties, it should be: spring.jpa.hibernate.ddl-auto=update As described in Ocds: spring.jpa.hibernate.ddl-auto= # DDL mode. This is actually a shortcut for the…
-
3
votes1
answer221
viewsA: When is the standard model request/Answer required in the context of a REST application?
Reasons for using this strategy: When you want to ensure that the interface with your API is immutable To prevent your API from behaving differently with each bank entity change, at the risk of…
-
0
votes1
answer251
viewsA: How to filter JSON objects through the fields of an array?
You can use some tool that offers reading through jsonpath expressions, as this site for example. With your JSON, you can apply expressions like $.ofertas..imagens, that will select all nodes from…
-
2
votes1
answer68
viewsA: Query in database returns incorrect data
The database data is probably being returned correctly, they should only be presented incorrectly on the screen. Overwrites the toString of your class Cargo to express the desired value: public…
-
5
votes1
answer461
viewsA: How to versioning the REST API URI address?
There are several approaches to versioning an API, but one should consider the context of the application that will expose that interface to the client. Let’s understand the API as a layer…
-
0
votes1
answer116
viewsA: Access Poke api via java eclipse
I recommend you use a client to call the API, and eliminate some configuration problems in the call you might have (like this 403 for example). For Java you can use the Pokeapi pokekotlin, the call…
-
0
votes1
answer1216
viewsA: List Filter in Java
Your code has a major problem which is the comparison of Strings, you can read more about it in that matter. Anyway, there are better ways to do what you need: import java.util.Arrays; import…
-
0
votes1
answer229
viewsA: Multiple shipments in Spring Boot
The problem lies in your data modeling, your class implementation GalleryModel does not have support for multiple photos since you are saving in a string: @Column(name="image", nullable=false)…
-
1
votes1
answer62
viewsA: Doubt Java Server Faces
With Primefaces 6.2 you can use the following command inside your Managed Bean: PrimeFaces.current().ajax().update("form:id:meu:campo"); In the case of pure JSF, you should add your field id in the…
-
1
votes1
answer219
viewsA: How to reference more than one ID attribute using the jpa API?
I will separate my answer into parts, answering your question: Yes, it is possible to have more than one annotation @Id in your class, however, This is a facility that Hibernate provides and is not…
-
4
votes1
answer516
viewsA: How to solve "Clean your tree for work"?
I can help you solve this using the terminal: Execute git stash to save your current changes Perform the operation you want (pull for example) Execute git stash pop to take your stash stack changes…
-
4
votes2
answers88
viewsA: Why isn’t my foreach cycle printing anything?
From what I understand your code is removing what it is other than empty and must be printing things blank. Switch to select(list, String::isEmpty); that will work…
-
1
votes1
answer81
viewsA: Ctrl+Click to open a Java class
If you are using Maven or some other dependency management tool, and the dependency has a source trailer it will be shown automatically. In the case of dependencies without source, you can use the…
-
1
votes1
answer47
viewsA: Download bytes docx api Rest
I suggest some changes to your download scheme, the second is not mandatory but I recommend it anyway: Utilize MediaType.APPLICATION_OCTET_STREAM since you work with several formats, this type is…
-
5
votes1
answer257
viewsA: How do I periodically trigger a function to update data in each instance of the Angular 5 application?
You can use the library Rx-Polling, with it you can make periodic requests by setting an interval. Follow an example: import {Component} from '@angular/core'; import {Http} from '@angular/http';…
-
0
votes1
answer59
viewsA: How to make an if comparing values with a list that is in an yml?
Missing include a getter for channel list: @ConfigurationProperties(prefix = "parceiros") @Component public class CanaisMapper { private List<String> canais = new ArrayList<String>();…
-
2
votes1
answer145
viewsA: How to make an if by comparing a value with a list in an yml?
I suggest you inject the values of your file using @ConfigurationProperties: @ConfigurationProperties(prefix="app") public class MinhaClasse { private List<String> canais = new…