如何在properties文件编写,才能在控制台换行?

如何在properties文件编写中换行?

package javaall;

/*@Component("employee")*/
/*请求代管,自动创建bean,id=employee*/
public class Employee {

    /*@Value("Employeename")*/
    private String name;
    /*@Value("worknumber")*/
    private String worknumber;

    public Employee() {
    }

    public Employee(String name, String worknumber) {
        this.name = name;
        this.worknumber = worknumber;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getWorknumber() {
        return worknumber;
    }

    public void setWorknumber(String worknumber) {
        this.worknumber = worknumber;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "name='" + name + '\'' +
                ", worknumber='" + worknumber + '\'' +
                '}';
    }
}

package javaall;

import cn.yys.one.Employee;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component("corp")
public class Corp {

    @Value("${corpName}")
    private String corpName;
    
    @Resource(name = "staff")
    private List<Employee> staff;

    public Corp() {
    }

    public Corp(String corpName, List<Employee> staff) {
        this.corpName = corpName;
        this.staff = staff;
    }

    public String getCorpName() {
        return corpName;
    }

    public void setCorpName(String corpName) {
        this.corpName = corpName;
    }

    public List<Employee> getStaff() {
        return staff;
    }

    public void setStaff(List<Employee> staff) {
        this.staff = staff;
    }

    @Override
    public String toString() {
        return "Corp{" +
                "corpName='" + corpName + '\'' +
                ", staff=" + staff +
                '}';
    }
}

package javaall;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {
    public static void main(String[] args) {
        String path = "spring/beans.xml";
        /*必须先指出xml文件的配置路径*/
        ApplicationContext context = new ClassPathXmlApplicationContext(path);
        Corp info = context.getBean(Corp.class,"corp");
        System.out.println(info);/*输出信息*/
    }
}

<?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:context="http://www.springframework.org/schema/context"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

    <!--注解java文件所在的包名-->
    <context:component-scan base-package="javaall" />
    <!--本机环境下寻找配置文件-->
    <context:property-placeholder location="spring/employee.properties"/>

    <!--构造注入Employee-->
    <bean id="staff-1" class="javaall.Employee">
        <constructor-arg index="0" value="韬韬"/>
        <constructor-arg index="1" value="0520"/>
    </bean>

    <!--设值注入Employee-->
    <bean id="staff-3" class="javaall.Employee">
        <property name="name" value="玺子"></property>
        <property name="worknumber" value="1128"></property>
    </bean>

    <!--注解注入-->
    <util:list id="staff">
        <ref bean="staff-1"/>
        <ref bean="staff-3"/>
    </util:list>
</beans>

corpName="可口可乐","天天向上"

输出结果:
在这里插入图片描述想要变成那种可以两个公司,相同员工,不知如何进行?

所以想请问各位大佬们,这个输出换行的问题该如何解决?我实在是找不到解决办法了。。。。。请求各位大佬帮我解答一下

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

是快卡黎嫩哦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值