Spring boot version: 2.6.0-M2

I have the following record:

@ConfigurationProperties(prefix = "foo.bar")
public record MyProperties(String a, String b) {}

Upon startup, I see this exception:

...
Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class {...}.MyProperties: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Cannot subclass final class {...}.MyProperties
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:209)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:478)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:342)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:291)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:437)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602)
... 48 common frames omitted
Caused by: java.lang.IllegalArgumentException: Cannot subclass final class {...}.MyProperties
at org.springframework.cglib.proxy.Enhancer.generateClass(Enhancer.java:660)
at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at org.springframework.cglib.core.ClassLoaderAwareGeneratorStrategy.generate(ClassLoaderAwareGeneratorStrategy.java:57)
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:358)
at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:585)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:131)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:319)
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:572)
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:419)
at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:57)
at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:206)
... 55 common frames omitted

Fwiw, I also have a few pointcuts and aop aspects declared.

Comment From: wilkinsona

By default, Spring Boot doesn't proxy @ConfigurationProperties classes or records. You must have something in your app (perhaps one of your point cuts?) that is causing the proxy to be created. From what you've described thus far, I think this is likely to be a problem in your application rather than in Spring Boot itself. If you believe that Spring Boot is, in fact, the cause and you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: wilkinsona

I've just realised this is a duplicate of https://stackoverflow.com/questions/69221447/spring-is-trying-to-subclass-a-record-component-when-aop-is-present. Please don't cross-post in this manner as it wastes people's time. Instead, please update your question on Stack Overflow with some minimal code to reproduce the problem as @mdeinum already requested.

Comment From: moxaj

I apologize, I was unaware that raising the problem on both stackoverflow and github is considered crossposting (how am I to know that the same people would be active on both platforms?). I'll update my so question with a minimal repro.

Comment From: wilkinsona

Thanks. The people who are active on each platform doesn't make a difference. Posting in two places, particularly without making it clear that you've done so, runs the risk of someone spending time trying to help you in one place when someone's already done so in another. That could happen when some, none or all of the same people are active on both platforms.