做网站没有数据,石家庄学设计的正规学校,html源码查看在线,好公司网站建设价格低1打开idea----new project 2点击建立项目的类型maven 点击next 3点击next 4选择路径#xff0c;点击完成 5建立成功之后修改pom.xml配置文件
添加#xff0c;解决依赖关系 dependenciesdependencygroupIdorg.springframework/groupIdar…1打开idea----new project 2点击建立项目的类型maven 点击next 3点击next 4选择路径点击完成 5建立成功之后修改pom.xml配置文件
添加解决依赖关系 dependenciesdependencygroupIdorg.springframework/groupIdartifactIdspring-context/artifactIdversion4.3.13.RELEASE/version/dependency
/dependencies
6在main下建立一个hello包----下面建立三个类 MesasageService类
package hello;public class MesasageService {/*** 执行打印功能* return 返回要打印的字符串*/public String getMessage(){return Hello World;}
}
MessagePrinter类
package hello;public class MessagePrinter {private MesasageService service;/** 简历和MessageService的关系* *///设置service的值public void setService(MesasageService service){this.service service;}public void printMessage(){System.out.println(this.service.getMessage());}
}application类
package hello;import javax.print.attribute.standard.RequestingUserName;public class Application {public static void main(String[] args){System.out.println(application );//创建打印机对象MessagePrinter printer new MessagePrinter();//创建消息服务对象MesasageService service new MesasageService();//设置打印机属性printer.setService(service);//打印消息printer.printMessage();}
}运行结果 application
Hello World