refactor(ioc): 重构部门实体配置并更新项目依赖

- 将Department实体的属性从deptCode/college/dean/phone改为deptNo/deptManager/deptPhone/campus
- 在bean-ioc.xml中为Department实体添加第二个实例department2用于测试
- 更新主校区和东校区的校园信息配置
- 添加javax.servlet-api-4.0.1.jar到项目依赖库中
- 移除多个废弃的注解配置相关Java类文件
- 清理过时的XML配置文件和项目配置文件
main
CesarH 1 month ago
parent 96d6ea8a40
commit 8343420ba9

@ -19,6 +19,7 @@
<root url="jar://$PROJECT_DIR$/grademanagement/web/WEB-INF/lib/spring-web-5.1.6.RELEASE.jar!/" />
<root url="jar://$PROJECT_DIR$/grademanagement/web/WEB-INF/lib/commons-dbcp2-2.5.0.jar!/" />
<root url="jar://$PROJECT_DIR$/grademanagement/web/WEB-INF/lib/mybatis-spring-2.0.3.jar!/" />
<root url="jar://$PROJECT_DIR$/grademanagement/web/WEB-INF/lib/javax.servlet-api-4.0.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />

@ -1,29 +0,0 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="commons-logging-1.1.1" level="project" />
</component>
</module>

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>

@ -1,39 +0,0 @@
package com.ssm.di.annotation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
// 标记这个类交给Spring管理id默认是category
@Component
public class Category {
// 专业ID
@Value("1")
private Integer cid;
// 专业名称
@Value("软件工程")
private String cname;
// 专业介绍(可选,可根据课程需求调整)
@Value("培养软件开发、系统设计方向的应用型人才")
private String description;
// 无参构造Spring必须
public Category() {}
// Getter/SetterSpring注入需要
public Integer getCid() { return cid; }
public void setCid(Integer cid) { this.cid = cid; }
public String getCname() { return cname; }
public void setCname(String cname) { this.cname = cname; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
// 打印信息用
@Override
public String toString() {
return "专业信息{" +
"专业ID=" + cid +
", 专业名称='" + cname + '\'' +
", 专业介绍='" + description + '\'' +
'}';
}
}

@ -1,17 +0,0 @@
package com.ssm.di.annotation.annotation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class Category {
@Value("1")
private Integer cid;
@Value("蔬菜")
private String cname;
@Override
public String toString() {
return "Category{cid=" + cid + ", cname='" + cname + "'}";
}
}

@ -1,30 +0,0 @@
package com.ssm.di.annotation.annotation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class Product {
@Value("2")
private Integer pid;
@Value("荷兰豆")
private String pname;
@Value("12.9")
private Double marketPrice;
@Value("12.0")
private Double shopPrice;
@Value("products/f4c77d4e-57ca-4f95-8b03")
private String image;
// 必须重写 toString() 才能输出截图中的格式
@Override
public String toString() {
return "Product{" +
"pid=" + pid +
", pname='" + pname + '\'' +
", marketPrice=" + marketPrice +
", shopPrice=" + shopPrice +
", image='" + image + '\'' +
'}';
}
}

@ -1,9 +0,0 @@
package com.ssm.di.annotation.annotation;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan("com.ssm.di.annotation")
public class SpringConfig {
}

@ -1,13 +0,0 @@
package com.ssm.di.annotation.annotation;
import com.ssm.di.annotation.Category;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
public class Test {
public static void main(String[] args) {
ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
com.ssm.di.annotation.Category category = context.getBean(Category.class);
System.out.println(category);
}
}

@ -1,12 +0,0 @@
package com.ssm.first;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class FirstTest {
public static void main(String[] args) {
//初始化Sping容器加载配置文件
ApplicationContext ac=new ClassPathXmlApplicationContext("bean-first.xml");
System.out.printf("Hello Sping!");
}
}

@ -56,19 +56,19 @@
<bean id="department" class="com.ssm.ioc.Department">
<property name="deptId" value="1001"/>
<property name="deptName" value="计算机科学与技术系"/>
<property name="deptCode" value="CS001"/>
<property name="college" value="信息工程学院"/>
<property name="dean" value="张教授"/>
<property name="phone" value="13800138000"/>
<property name="deptNo" value="CS001"/>
<property name="deptManager" value="张教授"/>
<property name="deptPhone" value="13800138000"/>
<property name="campus" value="主校区"/>
</bean>
<!-- 可补充其他院系实例,用于测试 -->
<bean id="department2" class="com.ssm.ioc.Department">
<property name="deptId" value="1002"/>
<property name="deptName" value="电子信息工程系"/>
<property name="deptCode" value="EE001"/>
<property name="college" value="信息工程学院"/>
<property name="dean" value="李教授"/>
<property name="phone" value="13900139000"/>
<property name="deptNo" value="EE001"/>
<property name="deptManager" value="李教授"/>
<property name="deptPhone" value="13900139000"/>
<property name="campus" value="东校区"/>
</bean>
</beans>

@ -59,7 +59,17 @@
<property name="deptNo" value="CS001"/>
<property name="deptManager" value="张教授"/>
<property name="deptPhone" value="13800138000"/>
<property name="campus" value="信息工程学院"/>
<property name="campus" value="主校区"/>
</bean>
<!-- 可补充其他院系实例,用于测试 -->
<bean id="department2" class="com.ssm.ioc.Department">
<property name="deptId" value="1002"/>
<property name="deptName" value="电子信息工程系"/>
<property name="deptNo" value="EE001"/>
<property name="deptManager" value="李教授"/>
<property name="deptPhone" value="13900139000"/>
<property name="campus" value="东校区"/>
</bean>

Loading…
Cancel
Save