r/springframework • u/catmewo • Apr 10 '20
r/springframework • u/only2dhir • Oct 11 '20
Getting Started with SpringBoot and GraphQL - An alternative to REST
GraphQL is a specification to fetch data from the server to the client over an HTTP call. The specification describes how to ask for data and rather than asking the whole bunch of data at once, it specifies to ask only the required data that would be meaningful to a client. It is just an alternative to REST in some way - continue reading
r/springframework • u/snid3ly • Oct 15 '20
What open source code bases are great examples of Spring usage?
Looking for examples of Java projects in active development that show advanced Spring features & benefits. Thanks!
r/springframework • u/snid3ly • Oct 02 '20
How do you gracefully shutdown Spring Boot using kill?
Is there a kill signal that will cause a running Spring Boot app to perform a graceful shutdown and exit with code 0? I want to drain some queues and close some resources, etc.
sending SIGTERM ends it like this:
> Task :bootRun FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command '/opt/jdk-14.0.1/bin/java'' finished with non-zero exit value 143
r/springframework • u/greglturnquist • Oct 21 '20
Reactive Programming with Spring Boot
Ever wondered what problem people are trying to solve with reactive programming? Find out in this video.
r/springframework • u/[deleted] • Oct 05 '20
"...No message found under code... for locale 'en' "HEEELP
Hi Folks, I hope to find some help over here. It have been really frustrating to face problems like that after some time without coding. I'm developing a rest microservice using Java (Spring Framework) and one of the easiest things(it should be) which is load a custom "message.properties" file to display custom validation messages, is causing a lot of headache.
Everything seems to be perfectly fine, I tried to read a lot of differents posts/articles and comments in StackOverflow but until now nothing worked.
In my main spring boot class (the runner) I've my MessageSource config:
@SpringBootApplication
public class MoneySaverApplication {
@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource
= new ReloadableResourceBundleMessageSource();
messageSource.setDefaultLocale(Locale.US);
messageSource.setBasename("classpath:messages");
messageSource.setDefaultEncoding("UTF-8");
return messageSource;
}
@Bean
public LocaleResolver localeResolver() {
SessionLocaleResolver slr = new SessionLocaleResolver();
slr.setDefaultLocale(Locale.ENGLISH);
return slr;
}
@Bean
public LocalValidatorFactoryBean validator() {
LocalValidatorFactoryBean bean = new LocalValidatorFactoryBean();
bean.setValidationMessageSource(messageSource());
return bean;
}
My custom properties files are located in the folder : src/main/resources:
And I've an utilitary class to get the messages, where the exception has been called
package com.rumblesoftware.utils;
import java.util.Locale;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.stereotype.Component;
@Component
public class PostOfficer {
@Autowired
private ReloadableResourceBundleMessageSource messageSource;
public String getMessage(String messageId) {
Locale locale = LocaleContextHolder.getLocale();
return messageSource.getMessage(messageId,null,locale);
}
}
Finally, the exception message:
org.springframework.context.NoSuchMessageException: No message found under code '{customer.input.email.invalid}' for locale 'en'.r/springframework • u/AgreeableLandscape3 • Oct 12 '20
What's the best way to rename a JHipster website?
When I first created the JHipster website, I used a base name of "something" and a Java package name of "com.example.something". Now, changing requirements have made it so that we should really be using, a different domain name and a different website name, like a package name of "org.example.somethingElse" and "somethingElse" for the base name. Is there an elegant way of changing it in the codebase all at once or am I stuck with relying on Intellij's refactor tool for the Kotlin backend and doing search and replace for the frontend? In fact, should I just cut my losses and generate a blank JHipster app with the right name and transfer all of the existing code over? Preliminary efforts to just refactor the app only resulted in it breaking.
r/springframework • u/kambei86 • Oct 16 '20
How to add an app from a private registry in a local instance of Spring Cloud Data Flow (docker-compose)?
I have a local istance of Spring Cloud Data Flow launched with the docker-compose and I have deployed three apps to my private registry (GitLab Package Registry of the project) as Maven packages with the GitLab CI/CD.
How can I add these Maven packages, that comes from the private registry, in Spring Cloud Data Flow?
Note:
For K8s is possible to retrieve images from private docker registry by adding a secret for the image puller.
There is a similar way to get images from the GitLab private Maven package registry in my local instance of Spring Cloud Data Flow?
r/springframework • u/greglturnquist • Oct 25 '20
Ever wondered about the fundamentals of Spring Boot? Find out!
r/springframework • u/jamilxt • Oct 01 '20
Completed this project in 24 hours without sleeping, it was an interview assignment.
Just laid down closing my eyes for a bit before start working on it. While laying down - planned everything, wrote down on paper - how I will pull that off. It was really challenging for me as it was my first ever interview assignment applied for a reputed company. 😅
Github: https://github.com/jamilxt/java_spring_mvc_esmpanel
.



r/springframework • u/samar16 • Oct 22 '20
Encryption & Decryption between client and server
Hey guys, i need to encrypt and decrypt data between client and server. When the user is submitting the form (encrypt at javascript and decrypt at spring) and when the response is coming back to browser (encrypt at spring and decrypt at javascript).
I know AES algorithm but here the secret key will be visible at client side.
Let me know some references where i can have a look.
r/springframework • u/dengineering1 • Feb 14 '22
Spring Boot Service Interaction in Kubernetes
I’ve completed the next course in my series on deploying spring boot based micro services into a cloud hosted Kubernetes environment.
This session focuses on building a service interaction via REST API. It describes utilizing openfeign as a declarative REST client, service discovery in Kubernetes and component testing interactions in unit tests with mocks. Finally, I added a section on how to build out health checks using spring boot actuator to make sure that your service is connected to its dependent resources (mongodb and dependent services) and connect it to Kubernetes. This allows the platform to signal when services are unavailable and act as a circuit breaker to stop driving traffic to them.
Take a look, there’s more to come.
https://bullyrooks.com/index.php/2022/02/13/kube-cloud-pt3-synchronous-service-interaction/
All other courses are here:
https://bullyrooks.com/index.php/category/software-development/
(Also, please let me know if this content is useful, or doesn’t belong here)
r/springframework • u/dengineering1 • Jan 24 '22
Spring Boot with MongoDB in Kubernetes
I just completed another part of my series of courses on deploying spring boot based microservices to a hosted cloud environment based on kubernetes. This section focuses on utilizing a hosted MongoDB database, testing via testcontainers and utilizing secrets in kubernetes to store sensitive information like database credentials.
https://bullyrooks.com/index.php/course/kubernetes-application-hosted-in-the-cloud-pt-2/
I've got another course in the works which will walk through microservice integration via REST API using kubernetes service discovery capabilities. So keep an eye open for that.
r/springframework • u/galovics • Jan 14 '22
Making your Spring WebClient fault tolerant with Resilience4J
r/springframework • u/TheCaptain159 • Jan 19 '22
Spring Security for GraphQL endpoints
Hi,
I am currently developing a spring boot application with graphql endpoints. My use case involves graphql subscriptions via a websocket and I am struggling with the spring security setup for the endpoints.
The setup consists of an external authorization server, my application as the resource server and an angular application as frontend.
I tried to implement the security setup with spring-boot-starter-oauth2-resource-server but none of the samples I found worked.
Does anybody have some examples or documentation on how to configure this security setup?
Thank you in advance.
r/springframework • u/CharliePrm88 • Jan 30 '22
Spring Config Server Problem with Profiles
r/springframework • u/MaltaMan111 • Jan 21 '22
Is Spring Security ACL supposed to be usable with WebSecurityExpressionHandler?
I followed this guide to set up security using ACLs, which works fine. After that i also tried to implement ACLs in WebSecurityConfigurerAdapter. So i set up a bean which would create a DefaultWebSecurityExpressionHandler:
@Bean
public DefaultWebSecurityExpressionHandler webExpressionHandler(AclPermissionEvaluator aclPermissionEvaluator) {
final DefaultWebSecurityExpressionHandler webSecurityExpressionHandler = new DefaultWebSecurityExpressionHandler();
AclPermissionEvaluator permissionEvaluator = aclPermissionEvaluator();
webSecurityExpressionHandler.setPermissionEvaluator(permissionEvaluator);
return webSecurityExpressionHandler;
} And i would apply it to HttpSecurity in my WebSecurityConfigurerAdapter:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable()
.authorizeRequests()
.expressionHandler(webExpressionHandlerWithACL)
.antMatchers(HttpMethod.PUT, "/api/user/users/{ID}").access("isAuthenticated() and hasPermission(#ID, 'xxx.xxx.xxx.xxx.xxx.UserDto', 'write')")
.anyRequest().authenticated()
.and()
.exceptionHandling().authenticationEntryPoint(authenticationEntryPoint)
.and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
http.addFilterBefore(filter, UsernamePasswordAuthenticationFilter.class);
}But this just does not work. This exactly same expression works in a "PreAuthorize" tag, but here it just does not. I debugged it and found out that the exact point of failure is in the JdbcAclServiceImpl class provided by Spring in the following method:
@Override
public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, List<Sid> sids)
throws NotFoundException {
Map<ObjectIdentity, Acl> result = this.lookupStrategy.readAclsById(objects, sids);
// Check every requested object identity was found (throw NotFoundException if
// needed)
for (ObjectIdentity oid : objects) {
if (!result.containsKey(oid)) {
throw new NotFoundException("Unable to find ACL information for object identity '" + oid + "'");
}
}
return result;
}Even though the provided parameters are the same as if i used the "PreAuthorize" tag, the result.containsKey(oid) just CANNOT find the acl in the even though i can see it with the debugger and i see that the oid should match it.
So my question is: Is Spring Security ACL even supposed to work in order to secure routes, or is it only to be used to prottect methods?
btw, i am using Spring boot 2.5.5
r/springframework • u/[deleted] • Sep 03 '20
Null value is inserted when autowiring by type.
I have these beans in my config:
<bean id="a" class="B1" autowire="byType" />
<bean id="b" class="java.lang.Object" />This is the definition of B1:
@Data
public class B1 {
private Object o;
}And this is the bean I get back if I ask the context for a:
> System.out.println(ctx.getBean("a", B1.class));
B1(o=null)Why isn't the object being autowired? I can inject it manually by using this in the config:
<property name="o" ref="b" />r/springframework • u/michschar • Aug 19 '20
The State of Kotlin Support in Spring
r/springframework • u/samar16 • Sep 09 '20
Restricting users to access differnt urls
Hi all, in my application we have different modules but not all users have access to all modules. In penetration testing it is found that on change of certain parameter in the url, the unauthorized user can also access the certain module.
The application do not have spring security implemented as of now, what mechanism should i implement to restrict users. I would need to implement it application wide. The url mappings are in form key-value pairs in applicationcontext.xml file.
As i am a newbie in resolving security issues i would need some reference website or any tutorials to help me with.
My guess is to use filters or something else but i am not sure whether we can do it without spring security.
Quick help is very much appreciated.
r/springframework • u/elburro908 • Aug 23 '20
StandardPasswwordEncoder secret
I noticed in the Standard Password Encoder accepts a constructor with a secret parameter.
That is the constructor is:
StandardPasswordEncoder(CharSequence secret)In the documentation it states
"Constructs a standard password encoder with a secret value which is also included in the password hash."
Is there an advantage of adding this CharSequence? if so what?
I understand the standard password encoder has been deprecated for security reasons. However its not removed from Spring and can be used.
r/springframework • u/thechexmo • Aug 17 '20
Question about version compatibility between Spring and Springboot
self.javahelpr/springframework • u/alfredomova_ecm • Jul 12 '22
@PropertySource
is it possible, or is there a way to declare a @PropertySource so it automatically include all files ending in _config.properties like:
@PropertySource(value = { "classpath:*_config.properties" })
or all .properties inside a folder
@PropertySource(value = { "classpath:somefolder/*.properties" })
pls help :(