by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:38
    busches opened #23413
  • 13:55
    jmussman commented #14064
  • Sep 19 21:25
    philwebb commented #23387
  • Sep 19 21:24
    philwebb commented #23387
  • Sep 19 21:21
    philwebb closed #23387
  • Sep 19 21:21

    philwebb on master

    Fix LoggingSystem package tangl… (compare)

  • Sep 19 21:21
    philwebb milestoned #23387
  • Sep 19 21:21
    philwebb demilestoned #23387
  • Sep 19 21:12
    philwebb labeled #23411
  • Sep 19 21:12
    philwebb milestoned #23411
  • Sep 19 21:12
    philwebb unlabeled #23411
  • Sep 19 21:12
    philwebb labeled #23411
  • Sep 19 21:11
    philwebb commented #23411
  • Sep 19 20:50
    spring-issuemaster labeled #23412
  • Sep 19 20:49
    raphw opened #23412
  • Sep 19 13:23
    sdeleuze commented #23387
  • Sep 19 13:11
    sdeleuze commented #22594
  • Sep 19 07:33
    rgoers commented #5479
  • Sep 18 19:23
    scottfrederick milestoned #23400
  • Sep 18 19:23
    scottfrederick demilestoned #23400
Mohanraj Nagasamy
@mohanraj-nagasamy
Im using boot 2.2.2 - Am I missing something?
Scott Frederick
@scottfrederick
@mohanraj-nagasamy How are you registering the listener?
from the docs link above, Some events are actually triggered before the ApplicationContext is created, so you cannot register a listener on those as a @Bean.. The ApplicationEnvironmentPreparedEvent is one of those.
Mohanraj Nagasamy
@mohanraj-nagasamy
Its working after adding to spring.factories. Thanks @scottfrederick
Steve D
@sdavids13

Speaking of ApplicationListeners, I am banging my head with what seems like a bug with auditing OAuth 2.0 failed login attempts and documented my findings here: spring-projects/spring-security#7793

I am trying to work around the current problem by trying to wire up my own AuthenticationEventPublisher in the WebSecurityConfigurerAdapter but even that doesn't seem to configure the correct event publisher. Anyone have any thoughts on what I might be missing?

Andy Wilkinson
@wilkinsona
@emersonf Declaring them as <scope>runtime</scope> makes no difference for a consuming project in Maven. Until relatively recently it made no difference in Gradle either. I can't remember exactly when it changed, but have a vague recollection that it may have been in a 5.x release. We've yet to catch up with that change. That may change in Boot 2.3 as, all being well, we'll publish Gradle metadata for all of Boot's modules, including its starters.
Alex Czar
@AlexCzar
@wilkinsona does publishing gradle metadata mean it'll finally be fully safe to use implementation(platform(springBootBom)) instead of spring dependencies plugin? That would be huge.
Ravi Chandra
@rchandra3007

hello, I'd like to dynamically create n instances of a CommandLineRunner implementation that I have. Basically I have files that I need to process, and for each file on startup I'd like to have a separate command line runner instance. I thought I could achieve this with BeanFactoryPostProcessor. The following is a snippet.

@Configuration
public class RunnersConfiguration {

    @Bean
    public BeanFactoryPostProcessor beanFactoryPostProcessor() {
        return (ConfigurableListableBeanFactory bf) -> {
            try {
                Files.list(Paths.get("src/main/resources"))
                        .filter(p -> p.endsWith(".csv"))
                        .map(p -> new CsvRunner(p))
                         .forEach(r -> bf.registerSingleton("csvRunner" + r.getFilepath(), r));
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        };
    }

}

My assumption was that after these runners were registered, spring would continue things as normal and would run the run method of the CommandLineRunner implementations. However this doesn't verify. Am I using the right class? Is this behaviour just wrong?
thanks in advance.

Ulvi
@JeRiF74
Please guys somebody hear , can you help me during 1 week to build my own a little really small project using Spring , I want that my project interact with database , have a enough functionality and some view for coolness) I want to make it step by step , one of your can help my life , my email address is jerif194@gmail.com , I need to will get a work as developer , I learn spring more then 1 month and I a little bit confused , thank you guys.
Andy Wilkinson
@wilkinsona
@AlexCzar What do you mean by "safe"? You can do that today if you wish to do so. There are some things that won't work (overriding of version properties, for example) but I don't think Gradle's own metadata will help with that.
Emerson Farrugia
@emersonf
James Howe
@OrangeDog
There's a class WithoutTransactionOperations but it's not public and I don't see how you're supposed to configure one (e.g. for tests).
Not sure why I couldn't find it: TransactionOperations.withoutTransaction()
Steve D
@sdavids13

I am trying to setup my own spring starter for my own security configuration which seems to work fine when running the application, but when i try to create mock mvc tests it won't load up my WebSecurityConfigurerAdapter when the following conditional is specified: @ConditionalOnMissingBean(WebSecurityConfigurerAdapter.class).

I tried this:

@SpringBootTest
@AutoConfigureMockMvc
public class WebSecurityTests {

  @Autowired
  private MockMvc mockMvc;

  @MockBean JwtDecoder jwtDecoder;

  @SpringBootApplication(exclude = {SecurityAutoConfiguration.class, UserDetailsServiceAutoConfiguration.class})
  public static class TestConfig {
    @RestController
    public class MockController {
      @RequestMapping(path = "/", method = {RequestMethod.HEAD, RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.PATCH})
      public String access(HttpServletRequest request) {
        return request.getMethod();
      }
    }
  } 
...

With this in an auto configuration definition:

@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(WebSecurityConfigurerAdapter.class)
@ConditionalOnWebApplication(type = Type.SERVLET)
public class WebSecurityConfiguration {
....
  @EnableWebSecurity
  @Configuration(proxyBeanMethods = false)
  @ConditionalOnMissingBean(WebSecurityConfigurerAdapter.class)
  @Order(SecurityProperties.BASIC_AUTH_ORDER)
  static class DefaultConfigurerAdapter extends WebSecurityConfigurerAdapter {
...

With @ConditionalOnMissingBean(WebSecurityConfigurerAdapter.class) it seems like no access control takes place, when I remove @ConditionalOnMissingBean(WebSecurityConfigurerAdapter.class) all my tests pass, but this will prevent me from being able to override the WebSecurityConfigurerAdapter if needed in my other projects. Any thoughts on how to resolve this?

Stéphane Nicoll
@snicoll
something else is creating WebSecurityConfigurerAdapter, check the auto-configuration report to figure out
NicklasWallgren
@NicklasWallgren

Hey,

It seems like the WebSocketMessageBrokerConfigurer doesn't play nice with spring.main.lazy-initialization=true in Spring Boot 2.2. The clients get stuck on the CONNECT-phase, and does not retrieve a CONNECTED message.

I have added @Lazy(false) in our WebSocketMessageBrokerConfigurer bean, but it didn't do any difference.

Does anyone have any pointers?

Joel Sina
@joel.sina_gitlab
Hello to everyone, a quick question on how to handle multiple type users. So I have the need to have 2 types of Users, User1 and User2. User1 and User2 can both create Events, but only User1 can comment. Right now I have an AbstractUser class that is extended by User1 and User2. Inside the AbstractUser i have a boolean canComment that is set to true by default and overrided by User2 to false. Then in my endpoint i retrieve from JPA the AbstractUser and check if he canComment, then proceed. The AbstractUser is declared as an entity with @Inheritance on Single Table and @DiscriminatorColumn. It doesn't feel to be the right way in my eyes so i'm here asking you for this.
Andy Wilkinson
@wilkinsona
@NicklasWallgren It sounds like one or more beans need to be made eager. You can do that with a org.springframework.boot.LazyInitializationExcludeFilter bean. I'd need to dig a bit more to know which bean or beans it is that need to be eager.
Nikolaob96
@Nikolaob96
Did anyone use ContextMenu with JavaFx ? im creating a autocomplete box, and i have a problem that it stays scrolled down if i scroll it down even after typing new term in the field.. I cant seem to find any method or a way to extract scrollbar and scroll it up on every search? Anyone know if i can manipulate the scrollbar of contextmenu somehow please?
kivi
@kivi

I have a service, wich already has a server and so on. But I would like to have continuous build environment, so that changes hot reloaded and I can debug and test out some things. (that java app is quite big and has no tests, some things I don't even understand yet, and I have to fix some bugs)

I wonder if I can just start the java app with spring boot and the rest stays as it is.

Zheng Wang
@echooymxq

I don't know if this is a bug. I have two configuration files defined in the resources directory.
application.properties:

role.id=456

application.yml

user:
  id: 123
@Bean
public CommandLineRunner runner(Environment environment) {
    return args -> {
        Object userId = environment.getProperty("user.id", Object.class);
        Integer user_id = (Integer) userId;

        // ClassCastException: java.lang.String cannot be cast to java.lang.Integer
        Object roleId = environment.getProperty("role.id", Object.class);
        Integer role_id = (Integer) roleId;
    };
}

Does this mean that properties and yaml are inconsistent?

@wilkinsona
Phil Webb
@philwebb
YAML parsing will indeed create Integer entries for elements that it thinks are numbers where as Properties files are always inserted as Strings.
I think if you do environment.getProperty("role.id", Integer.class); then Spring will convert the String to and Integer
Zheng Wang
@echooymxq
Yes, including other types, such as Boolean. I just found that there are differences between the two methods. Should n’t they be unified?
Phil Webb
@philwebb
The only option we'd have is to change YAML to always insert Strings but I think that might end up causing other problems.
For example the source YAML can use a lot of different values for booleans https://yaml.org/type/bool.html
The YAML parser we use takes care of these and gives us a boolean
I think it's probably best just to store that, rather than converting it to a String
especially as the String would likely need to be converted back to Boolean when it's used
Zheng Wang
@echooymxq
In some cases, people define a metadata: Map <String, Object>. with properties or yaml, It has different handling of type conversion when get the values.
I agree with you very much. This problem is more troublesome.
NicklasWallgren
@NicklasWallgren
@wilkinsona Alright, I will look into it. Thanks
Sruti
@Su-s
how we can go to the redirect page which is redirecting by the controller in reactjs frontend
@GetMapping("/admin-login")
public void adminLogin(HttpServletResponse response) {
    try {
        String url = AUTH_URL + "?" + "response_type=code" + "&" + "client_id=" + CLIENT_ID + "&" + "redirect_uri="
                + REDIRECT_URI + "&" + "scope=" + SCOPE + "&" + "state=" + UUID_;
        response.sendRedirect(url);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
here's my controller
A C SREEDHAR REDDY
@a-c-sreedhar-reddy
you could just send http response and based on that in front end you can choose to redirect or stay in the same page
Sruti
@Su-s
adminLogin = ()=> {
axios(/adminLogin, {
method: "GET",
header: {
Accept: "application/json"
}
})
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error);
handleError(error);
});
this is the frontend part
A C SREEDHAR REDDY
@a-c-sreedhar-reddy
and admin-login should be post method which accepts username and password in the body
and you would authenticate and send a sessionID or JWT token as response
Sruti
@Su-s
i didnt get that
A C SREEDHAR REDDY
@a-c-sreedhar-reddy
or 401 if authentication error
Sruti
@Su-s
here im getting a cors error in frontend
Martijn Hoekstra
@martijnhoekstra
''''''
Witold Kupś
@Azbesciak
Did anyone have a problem with 414 responses via webClient? In my scenario consuming api returns HTML (nginx) default response (unexpected - it should be some kind of json), and it is even bearable - the worse is that it only occurs on production... because in my environment the request just hungs down (or response actually). I am on windows, production is on ubuntu
EugeneZakhno
@EugeneZakhno
image.png
Can you help me?