Spring Framework version
当我用该版本写c标签时c标签的的name值赋值到了age上,age标签的值赋值到了name上。
当我的版本更换到
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.0.0</version>
</dependency>
我认为6.1.0-M2的这个版本c标签存在问题
Comment From: snicoll
I am sorry but we can't give you support based on screenshots of code. I understand you think you've found a bug in the way c:
is handled, but I am not sure what it is.
Please replace those screenshot by a small sample that we can run ourselves. It can either be a zip file of the project attached to this issue or a link to another GitHub repository with the code.
Comment From: xiaoguan777
springTest.zip 你可以运行模块springTest-bug中test目录下的TestPeople文件,得到结果为
而运行模块springTest-normal中test目录下的TestPeople文件,得到结果为 
两个模块只有spring-context的版本不同,其他文件都为
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:c="http://www.springframework.org/schema/c"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="peopleBean" class="com.xiaoguan.bean.People" c:name="1" c:age="2" c:sex="3" />
</beans>
package com.xiaoguan.bean;
public class People {
private String name;
private String age;
private String sex;
@Override
public String toString() {
return "People{" +
"name='" + name + '\'' +
", age='" + age + '\'' +
", sex='" + sex + '\'' +
'}';
}
public People(String name, String age, String sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
}
package com.xiaoguan.test;
import com.xiaoguan.bean.People;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestPeople {
@Test
public void testC(){
ApplicationContext applicationContext=new ClassPathXmlApplicationContext("spring-c.xml");
People peoplec = applicationContext.getBean("peopleBean", People.class);
System.out.println(peoplec);
}
}
第一个模块版本为:
<repository>
<id>repository.spring.milestone</id>
<name>Spring Milestone Repository</name>
<url>https://repo.spring.io/milestone</url>
</repository>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.1.0-M2</version>
</dependency>
第二个模块版本为
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.0.0</version>
</dependency>
**Comment From: snicoll**
Thanks for the sample. It's a bit odd that the 6.0 version does not produce a warning but you were relying on parameter names to be discovered from the byte code and we've dropped support for that, [as described in the release notes](https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#core-container).
You need to compile your code with `-parameters`. You can achieve that with the following configuration.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<parameters>true</parameters>
</configuration>
</plugin>
</plugins>
</build>
Adding the above to the "bug" project produces a similar result as the "normal" project.
@jhoeller I am surprised that the 6.0.x version did not produce a warning for this. Is it normal?
**Comment From: xiaoguan777**
I understand. Thank you for your patient answer.