This commit is contained in:
zzh 2024-09-15 23:55:31 +08:00
parent 2fb15a58f6
commit 8cf30b2136
100 changed files with 783 additions and 1619 deletions

View File

@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/JavaEE.iml" filepath="$PROJECT_DIR$/.idea/JavaEE.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/javaEE-master(1).iml" filepath="$PROJECT_DIR$/.idea/javaEE-master(1).iml" />
</modules>
</component>
</project>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/javaEE" vcs="Git" />
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -2,21 +2,20 @@
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="spring" />
<module name="project" />
<module name="task1" />
<module name="springboot" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="project" target="18" />
<module name="spring" target="1.8" />
</bytecodeTargetLevel>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="springboot" options="-parameters" />
<module name="task1" options="-parameters" />
</option>
</component>

View File

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="202101080136@106.53.194.250" uuid="4dee9987-e521-4a22-bf1c-a127b1cfd716">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<imported>true</imported>
<remarks>$PROJECT_DIR$/springboot/src/main/resources/application.properties</remarks>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://106.53.194.250:63306/202101080136?serverTimezone=UTC</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.resource.type" value="Deployment" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="202101080103@106.53.194.250" uuid="90e5caf5-88b9-4a6f-a481-f697a5210e90">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
<imported>true</imported>
<remarks>$PROJECT_DIR$/springboot/src/main/resources/application.properties</remarks>
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mysql://106.53.194.250:63306/202101080103?serverTimezone=UTC</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.host.port" />
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
<property name="com.intellij.clouds.kubernetes.db.container.port" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

View File

@ -5,7 +5,6 @@
<file url="file://$PROJECT_DIR$/project/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/spring/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/spring/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/springboot/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/task1/src/main/java" charset="UTF-8" />
</component>
</project>

View File

@ -4,14 +4,21 @@
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/task1/pom.xml" />
<option value="$PROJECT_DIR$/spring/pom.xml" />
<option value="$PROJECT_DIR$/project/pom.xml" />
<option value="$PROJECT_DIR$/springboot/pom.xml" />
<option value="$PROJECT_DIR$/task1/pom.xml" />
</list>
</option>
<option name="ignoredFiles">
<set>
<option value="$PROJECT_DIR$/project/pom.xml" />
<option value="$PROJECT_DIR$/spring/pom.xml" />
<option value="$PROJECT_DIR$/springboot/pom.xml" />
</set>
</option>
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="corretto-18" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="corretto-18" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/javaEE.iml" filepath="$PROJECT_DIR$/.idea/javaEE.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/javaee.iml" filepath="$PROJECT_DIR$/.idea/javaee.iml" />
</modules>
</component>
</project>

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View File

@ -1,38 +0,0 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

View File

@ -1,8 +0,0 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/../springboot/src/main/java" charset="UTF-8" />
</component>
</project>

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/../springboot/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="18" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -1,124 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>project</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.1.12</version>
</dependency>
<dependency>
<groupId>com.spring</groupId>
<artifactId>spring</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,16 +0,0 @@
package org.example;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ApplicationObjectSupport;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Main {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("app.xml");
UserDao userDao = (UserDao) context.getBean("userDao");
userDao.findUser();
UserService userService = (UserService) context.getBean("userService",UserService.class);
userService.findUser();
}
}

View File

@ -1,7 +0,0 @@
package org.example;
public class UserDao {
public void findUser(){
System.out.println("查询用户数据");
}
}

View File

@ -1,18 +0,0 @@
package org.example;
public class UserService {
private UserDao userDao = null;
public UserDao getUserDao() {
return userDao;
}
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
}
public void findUser()
{
userDao.findUser();
}
}

View File

@ -1,18 +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 http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<!-- 开启注解-->
<bean id="userDao" class="com.spring.UserDao">
</bean>
<bean id="userService" class="com.spring.UserService">
<property name = "userDao" ref = "userDao" />
</bean>
<bean id="dbTools" class="com.spring.DBTools">
<property name="ip" value="127.0.0.1"/>
<property name="port" value="3306"/>
<property name="username" value="root"/>
</bean>
</beans>

View File

@ -1,8 +0,0 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="18" project-jdk-type="JavaSDK" />
</project>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings" defaultProject="true" />
</project>

View File

@ -1,31 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.spring</groupId>
<artifactId>spring</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>spring</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.1.12</version>
</dependency>
</dependencies>
</project>

View File

@ -1,27 +0,0 @@
package com.spring;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
ApplicationContext context = new ClassPathXmlApplicationContext("app.xml");
UserDao userdao = (UserDao) context.getBean("userDao");
userdao.findUser();
UserService userService = context.getBean("userService",UserService.class);
userService.findUser();
// DBTools dbtools = context.getBean("dbTools",DBTools.class);
// System.out.println(dbtools.getIp());
// System.out.println(dbtools.getUsername());
}
}

View File

@ -1,33 +0,0 @@
package com.spring;
public class DBTools {
private String ip;
private String port;
private String username;
public void setIp(String ip) {
this.ip = ip;
}
public void setPort(String port) {
this.port = port;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPort() {
return port;
}
public String getIp() {
return ip;
}
}

View File

@ -1,14 +0,0 @@
package com.spring;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
//@Component注解spring容器自动创建对象并且对象名就是类名首字母小写
//@Component
@Repository
//数据库增删改查的类一般用Dao结尾
public class UserDao {
public void findUser()
{
System.out.println("查询用户数据");
}
}

View File

@ -1,28 +0,0 @@
package com.spring;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
@Component
@Service
@Repository
@Controller
public class UserService {
@Autowired
private UserDao userDao;
public UserDao getUserDao() {
return userDao;
}
public void findUser() {
userDao.findUser();
}
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
}
}

View File

@ -1,16 +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"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.spring"/>
<!--
<bean id="userDao" class="com.spring.UserDao"/>
前面的userdao实例化的对象成员变量后面的spring容器里实例化对象的名字
<bean id="userService" class="com.spring.UserService">
<property name="userDao" ref="userDao"/>
</bean>
<bean id="dbTools" class="com.spring.DBTools"/>
-->
</beans>

View File

@ -1,38 +0,0 @@
package com.spring;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}

View File

@ -1,16 +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"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.spring"/>
<!--
<bean id="userDao" class="com.spring.UserDao"/>
前面的userdao实例化的对象成员变量后面的spring容器里实例化对象的名字
<bean id="userService" class="com.spring.UserService">
<property name="userDao" ref="userDao"/>
</bean>
<bean id="dbTools" class="com.spring.DBTools"/>
-->
</beans>

View File

@ -1,33 +0,0 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

View File

@ -1,19 +0,0 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.7/apache-maven-3.9.7-bin.zip

259
javaEE/springboot/mvnw vendored
View File

@ -1,259 +0,0 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Apache Maven Wrapper startup batch script, version 3.3.2
#
# Optional ENV vars
# -----------------
# JAVA_HOME - location of a JDK home dir, required when download maven via java source
# MVNW_REPOURL - repo url base for downloading maven distribution
# MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
# MVNW_VERBOSE - true: enable verbose log; debug: trace the mvnw script; others: silence the output
# ----------------------------------------------------------------------------
set -euf
[ "${MVNW_VERBOSE-}" != debug ] || set -x
# OS specific support.
native_path() { printf %s\\n "$1"; }
case "$(uname)" in
CYGWIN* | MINGW*)
[ -z "${JAVA_HOME-}" ] || JAVA_HOME="$(cygpath --unix "$JAVA_HOME")"
native_path() { cygpath --path --windows "$1"; }
;;
esac
# set JAVACMD and JAVACCMD
set_java_home() {
# For Cygwin and MinGW, ensure paths are in Unix format before anything is touched
if [ -n "${JAVA_HOME-}" ]; then
if [ -x "$JAVA_HOME/jre/sh/java" ]; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
JAVACCMD="$JAVA_HOME/jre/sh/javac"
else
JAVACMD="$JAVA_HOME/bin/java"
JAVACCMD="$JAVA_HOME/bin/javac"
if [ ! -x "$JAVACMD" ] || [ ! -x "$JAVACCMD" ]; then
echo "The JAVA_HOME environment variable is not defined correctly, so mvnw cannot run." >&2
echo "JAVA_HOME is set to \"$JAVA_HOME\", but \"\$JAVA_HOME/bin/java\" or \"\$JAVA_HOME/bin/javac\" does not exist." >&2
return 1
fi
fi
else
JAVACMD="$(
'set' +e
'unset' -f command 2>/dev/null
'command' -v java
)" || :
JAVACCMD="$(
'set' +e
'unset' -f command 2>/dev/null
'command' -v javac
)" || :
if [ ! -x "${JAVACMD-}" ] || [ ! -x "${JAVACCMD-}" ]; then
echo "The java/javac command does not exist in PATH nor is JAVA_HOME set, so mvnw cannot run." >&2
return 1
fi
fi
}
# hash string like Java String::hashCode
hash_string() {
str="${1:-}" h=0
while [ -n "$str" ]; do
char="${str%"${str#?}"}"
h=$(((h * 31 + $(LC_CTYPE=C printf %d "'$char")) % 4294967296))
str="${str#?}"
done
printf %x\\n $h
}
verbose() { :; }
[ "${MVNW_VERBOSE-}" != true ] || verbose() { printf %s\\n "${1-}"; }
die() {
printf %s\\n "$1" >&2
exit 1
}
trim() {
# MWRAPPER-139:
# Trims trailing and leading whitespace, carriage returns, tabs, and linefeeds.
# Needed for removing poorly interpreted newline sequences when running in more
# exotic environments such as mingw bash on Windows.
printf "%s" "${1}" | tr -d '[:space:]'
}
# parse distributionUrl and optional distributionSha256Sum, requires .mvn/wrapper/maven-wrapper.properties
while IFS="=" read -r key value; do
case "${key-}" in
distributionUrl) distributionUrl=$(trim "${value-}") ;;
distributionSha256Sum) distributionSha256Sum=$(trim "${value-}") ;;
esac
done <"${0%/*}/.mvn/wrapper/maven-wrapper.properties"
[ -n "${distributionUrl-}" ] || die "cannot read distributionUrl property in ${0%/*}/.mvn/wrapper/maven-wrapper.properties"
case "${distributionUrl##*/}" in
maven-mvnd-*bin.*)
MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/
case "${PROCESSOR_ARCHITECTURE-}${PROCESSOR_ARCHITEW6432-}:$(uname -a)" in
*AMD64:CYGWIN* | *AMD64:MINGW*) distributionPlatform=windows-amd64 ;;
:Darwin*x86_64) distributionPlatform=darwin-amd64 ;;
:Darwin*arm64) distributionPlatform=darwin-aarch64 ;;
:Linux*x86_64*) distributionPlatform=linux-amd64 ;;
*)
echo "Cannot detect native platform for mvnd on $(uname)-$(uname -m), use pure java version" >&2
distributionPlatform=linux-amd64
;;
esac
distributionUrl="${distributionUrl%-bin.*}-$distributionPlatform.zip"
;;
maven-mvnd-*) MVN_CMD=mvnd.sh _MVNW_REPO_PATTERN=/maven/mvnd/ ;;
*) MVN_CMD="mvn${0##*/mvnw}" _MVNW_REPO_PATTERN=/org/apache/maven/ ;;
esac
# apply MVNW_REPOURL and calculate MAVEN_HOME
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
[ -z "${MVNW_REPOURL-}" ] || distributionUrl="$MVNW_REPOURL$_MVNW_REPO_PATTERN${distributionUrl#*"$_MVNW_REPO_PATTERN"}"
distributionUrlName="${distributionUrl##*/}"
distributionUrlNameMain="${distributionUrlName%.*}"
distributionUrlNameMain="${distributionUrlNameMain%-bin}"
MAVEN_USER_HOME="${MAVEN_USER_HOME:-${HOME}/.m2}"
MAVEN_HOME="${MAVEN_USER_HOME}/wrapper/dists/${distributionUrlNameMain-}/$(hash_string "$distributionUrl")"
exec_maven() {
unset MVNW_VERBOSE MVNW_USERNAME MVNW_PASSWORD MVNW_REPOURL || :
exec "$MAVEN_HOME/bin/$MVN_CMD" "$@" || die "cannot exec $MAVEN_HOME/bin/$MVN_CMD"
}
if [ -d "$MAVEN_HOME" ]; then
verbose "found existing MAVEN_HOME at $MAVEN_HOME"
exec_maven "$@"
fi
case "${distributionUrl-}" in
*?-bin.zip | *?maven-mvnd-?*-?*.zip) ;;
*) die "distributionUrl is not valid, must match *-bin.zip or maven-mvnd-*.zip, but found '${distributionUrl-}'" ;;
esac
# prepare tmp dir
if TMP_DOWNLOAD_DIR="$(mktemp -d)" && [ -d "$TMP_DOWNLOAD_DIR" ]; then
clean() { rm -rf -- "$TMP_DOWNLOAD_DIR"; }
trap clean HUP INT TERM EXIT
else
die "cannot create temp dir"
fi
mkdir -p -- "${MAVEN_HOME%/*}"
# Download and Install Apache Maven
verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
verbose "Downloading from: $distributionUrl"
verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
# select .zip or .tar.gz
if ! command -v unzip >/dev/null; then
distributionUrl="${distributionUrl%.zip}.tar.gz"
distributionUrlName="${distributionUrl##*/}"
fi
# verbose opt
__MVNW_QUIET_WGET=--quiet __MVNW_QUIET_CURL=--silent __MVNW_QUIET_UNZIP=-q __MVNW_QUIET_TAR=''
[ "${MVNW_VERBOSE-}" != true ] || __MVNW_QUIET_WGET='' __MVNW_QUIET_CURL='' __MVNW_QUIET_UNZIP='' __MVNW_QUIET_TAR=v
# normalize http auth
case "${MVNW_PASSWORD:+has-password}" in
'') MVNW_USERNAME='' MVNW_PASSWORD='' ;;
has-password) [ -n "${MVNW_USERNAME-}" ] || MVNW_USERNAME='' MVNW_PASSWORD='' ;;
esac
if [ -z "${MVNW_USERNAME-}" ] && command -v wget >/dev/null; then
verbose "Found wget ... using wget"
wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
elif [ -z "${MVNW_USERNAME-}" ] && command -v curl >/dev/null; then
verbose "Found curl ... using curl"
curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
elif set_java_home; then
verbose "Falling back to use Java to download"
javaSource="$TMP_DOWNLOAD_DIR/Downloader.java"
targetZip="$TMP_DOWNLOAD_DIR/$distributionUrlName"
cat >"$javaSource" <<-END
public class Downloader extends java.net.Authenticator
{
protected java.net.PasswordAuthentication getPasswordAuthentication()
{
return new java.net.PasswordAuthentication( System.getenv( "MVNW_USERNAME" ), System.getenv( "MVNW_PASSWORD" ).toCharArray() );
}
public static void main( String[] args ) throws Exception
{
setDefault( new Downloader() );
java.nio.file.Files.copy( java.net.URI.create( args[0] ).toURL().openStream(), java.nio.file.Paths.get( args[1] ).toAbsolutePath().normalize() );
}
}
END
# For Cygwin/MinGW, switch paths to Windows format before running javac and java
verbose " - Compiling Downloader.java ..."
"$(native_path "$JAVACCMD")" "$(native_path "$javaSource")" || die "Failed to compile Downloader.java"
verbose " - Running Downloader.java ..."
"$(native_path "$JAVACMD")" -cp "$(native_path "$TMP_DOWNLOAD_DIR")" Downloader "$distributionUrl" "$(native_path "$targetZip")"
fi
# If specified, validate the SHA-256 sum of the Maven distribution zip file
if [ -n "${distributionSha256Sum-}" ]; then
distributionSha256Result=false
if [ "$MVN_CMD" = mvnd.sh ]; then
echo "Checksum validation is not supported for maven-mvnd." >&2
echo "Please disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
exit 1
elif command -v sha256sum >/dev/null; then
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | sha256sum -c >/dev/null 2>&1; then
distributionSha256Result=true
fi
elif command -v shasum >/dev/null; then
if echo "$distributionSha256Sum $TMP_DOWNLOAD_DIR/$distributionUrlName" | shasum -a 256 -c >/dev/null 2>&1; then
distributionSha256Result=true
fi
else
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2
echo "Please install either command, or disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties." >&2
exit 1
fi
if [ $distributionSha256Result = false ]; then
echo "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised." >&2
echo "If you updated your Maven version, you need to update the specified distributionSha256Sum property." >&2
exit 1
fi
fi
# unzip and move
if command -v unzip >/dev/null; then
unzip ${__MVNW_QUIET_UNZIP:+"$__MVNW_QUIET_UNZIP"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -d "$TMP_DOWNLOAD_DIR" || die "failed to unzip"
else
tar xzf${__MVNW_QUIET_TAR:+"$__MVNW_QUIET_TAR"} "$TMP_DOWNLOAD_DIR/$distributionUrlName" -C "$TMP_DOWNLOAD_DIR" || die "failed to untar"
fi
printf %s\\n "$distributionUrl" >"$TMP_DOWNLOAD_DIR/$distributionUrlNameMain/mvnw.url"
mv -- "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" "$MAVEN_HOME" || [ -d "$MAVEN_HOME" ] || die "fail to move MAVEN_HOME"
clean || :
exec_maven "$@"

View File

@ -1,149 +0,0 @@
<# : batch portion
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Apache Maven Wrapper startup batch script, version 3.3.2
@REM
@REM Optional ENV vars
@REM MVNW_REPOURL - repo url base for downloading maven distribution
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
@REM ----------------------------------------------------------------------------
@IF "%__MVNW_ARG0_NAME__%"=="" (SET __MVNW_ARG0_NAME__=%~nx0)
@SET __MVNW_CMD__=
@SET __MVNW_ERROR__=
@SET __MVNW_PSMODULEP_SAVE=%PSModulePath%
@SET PSModulePath=
@FOR /F "usebackq tokens=1* delims==" %%A IN (`powershell -noprofile "& {$scriptDir='%~dp0'; $script='%__MVNW_ARG0_NAME__%'; icm -ScriptBlock ([Scriptblock]::Create((Get-Content -Raw '%~f0'))) -NoNewScope}"`) DO @(
IF "%%A"=="MVN_CMD" (set __MVNW_CMD__=%%B) ELSE IF "%%B"=="" (echo %%A) ELSE (echo %%A=%%B)
)
@SET PSModulePath=%__MVNW_PSMODULEP_SAVE%
@SET __MVNW_PSMODULEP_SAVE=
@SET __MVNW_ARG0_NAME__=
@SET MVNW_USERNAME=
@SET MVNW_PASSWORD=
@IF NOT "%__MVNW_CMD__%"=="" (%__MVNW_CMD__% %*)
@echo Cannot start maven from wrapper >&2 && exit /b 1
@GOTO :EOF
: end batch / begin powershell #>
$ErrorActionPreference = "Stop"
if ($env:MVNW_VERBOSE -eq "true") {
$VerbosePreference = "Continue"
}
# calculate distributionUrl, requires .mvn/wrapper/maven-wrapper.properties
$distributionUrl = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionUrl
if (!$distributionUrl) {
Write-Error "cannot read distributionUrl property in $scriptDir/.mvn/wrapper/maven-wrapper.properties"
}
switch -wildcard -casesensitive ( $($distributionUrl -replace '^.*/','') ) {
"maven-mvnd-*" {
$USE_MVND = $true
$distributionUrl = $distributionUrl -replace '-bin\.[^.]*$',"-windows-amd64.zip"
$MVN_CMD = "mvnd.cmd"
break
}
default {
$USE_MVND = $false
$MVN_CMD = $script -replace '^mvnw','mvn'
break
}
}
# apply MVNW_REPOURL and calculate MAVEN_HOME
# maven home pattern: ~/.m2/wrapper/dists/{apache-maven-<version>,maven-mvnd-<version>-<platform>}/<hash>
if ($env:MVNW_REPOURL) {
$MVNW_REPO_PATTERN = if ($USE_MVND) { "/org/apache/maven/" } else { "/maven/mvnd/" }
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace '^.*'+$MVNW_REPO_PATTERN,'')"
}
$distributionUrlName = $distributionUrl -replace '^.*/',''
$distributionUrlNameMain = $distributionUrlName -replace '\.[^.]*$','' -replace '-bin$',''
$MAVEN_HOME_PARENT = "$HOME/.m2/wrapper/dists/$distributionUrlNameMain"
if ($env:MAVEN_USER_HOME) {
$MAVEN_HOME_PARENT = "$env:MAVEN_USER_HOME/wrapper/dists/$distributionUrlNameMain"
}
$MAVEN_HOME_NAME = ([System.Security.Cryptography.MD5]::Create().ComputeHash([byte[]][char[]]$distributionUrl) | ForEach-Object {$_.ToString("x2")}) -join ''
$MAVEN_HOME = "$MAVEN_HOME_PARENT/$MAVEN_HOME_NAME"
if (Test-Path -Path "$MAVEN_HOME" -PathType Container) {
Write-Verbose "found existing MAVEN_HOME at $MAVEN_HOME"
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"
exit $?
}
if (! $distributionUrlNameMain -or ($distributionUrlName -eq $distributionUrlNameMain)) {
Write-Error "distributionUrl is not valid, must end with *-bin.zip, but found $distributionUrl"
}
# prepare tmp dir
$TMP_DOWNLOAD_DIR_HOLDER = New-TemporaryFile
$TMP_DOWNLOAD_DIR = New-Item -Itemtype Directory -Path "$TMP_DOWNLOAD_DIR_HOLDER.dir"
$TMP_DOWNLOAD_DIR_HOLDER.Delete() | Out-Null
trap {
if ($TMP_DOWNLOAD_DIR.Exists) {
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
}
}
New-Item -Itemtype Directory -Path "$MAVEN_HOME_PARENT" -Force | Out-Null
# Download and Install Apache Maven
Write-Verbose "Couldn't find MAVEN_HOME, downloading and installing it ..."
Write-Verbose "Downloading from: $distributionUrl"
Write-Verbose "Downloading to: $TMP_DOWNLOAD_DIR/$distributionUrlName"
$webclient = New-Object System.Net.WebClient
if ($env:MVNW_USERNAME -and $env:MVNW_PASSWORD) {
$webclient.Credentials = New-Object System.Net.NetworkCredential($env:MVNW_USERNAME, $env:MVNW_PASSWORD)
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$webclient.DownloadFile($distributionUrl, "$TMP_DOWNLOAD_DIR/$distributionUrlName") | Out-Null
# If specified, validate the SHA-256 sum of the Maven distribution zip file
$distributionSha256Sum = (Get-Content -Raw "$scriptDir/.mvn/wrapper/maven-wrapper.properties" | ConvertFrom-StringData).distributionSha256Sum
if ($distributionSha256Sum) {
if ($USE_MVND) {
Write-Error "Checksum validation is not supported for maven-mvnd. `nPlease disable validation by removing 'distributionSha256Sum' from your maven-wrapper.properties."
}
Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash
if ((Get-FileHash "$TMP_DOWNLOAD_DIR/$distributionUrlName" -Algorithm SHA256).Hash.ToLower() -ne $distributionSha256Sum) {
Write-Error "Error: Failed to validate Maven distribution SHA-256, your Maven distribution might be compromised. If you updated your Maven version, you need to update the specified distributionSha256Sum property."
}
}
# unzip and move
Expand-Archive "$TMP_DOWNLOAD_DIR/$distributionUrlName" -DestinationPath "$TMP_DOWNLOAD_DIR" | Out-Null
Rename-Item -Path "$TMP_DOWNLOAD_DIR/$distributionUrlNameMain" -NewName $MAVEN_HOME_NAME | Out-Null
try {
Move-Item -Path "$TMP_DOWNLOAD_DIR/$MAVEN_HOME_NAME" -Destination $MAVEN_HOME_PARENT | Out-Null
} catch {
if (! (Test-Path -Path "$MAVEN_HOME" -PathType Container)) {
Write-Error "fail to move MAVEN_HOME"
}
} finally {
try { Remove-Item $TMP_DOWNLOAD_DIR -Recurse -Force | Out-Null }
catch { Write-Warning "Cannot remove $TMP_DOWNLOAD_DIR" }
}
Write-Output "MVN_CMD=$MAVEN_HOME/bin/$MVN_CMD"

View File

@ -1,93 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.zzh.springboot</groupId>
<artifactId>springboot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot</name>
<description>springboot</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.25</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,14 +0,0 @@
package com.zzh.springboot.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringbootApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
}
}

View File

@ -1,18 +0,0 @@
package com.zzh.springboot.springboot.controller;
import com.zzh.springboot.springboot.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class JsonController {
@RequestMapping("getuser")
@ResponseBody
public User getUser(){
User user = new User();
user.setUsername("周子豪");
user.setClassname("21医学信息工程");
return user;
}
}

View File

@ -1,42 +0,0 @@
package com.zzh.springboot.springboot.controller;
import com.zzh.springboot.springboot.model.Person;
import com.zzh.springboot.springboot.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
public class PersonController {
@Autowired
private PersonService personService;
@ResponseBody
@RequestMapping("getpersons")
public List<Person> getPersons(){
return personService.getPersons();
}
@RequestMapping("personList")
public String getPerson(Model model){
model.addAttribute("persons",personService.getPersons());
return "personList.html";
}
@RequestMapping("addpersonpage")
public String addPersonPage(){
return "addperson.html";
}
@RequestMapping("addperson")
public String addPerson(Person person){
personService.addPerson(person);
return "redirect:personList";
}
}

View File

@ -1,29 +0,0 @@
package com.zzh.springboot.springboot.controller;
import com.zzh.springboot.springboot.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.ArrayList;
import java.util.List;
@Controller
public class TestController {
@RequestMapping("test")
public String test(Model model){
List<User> userList = new ArrayList<>();
for (int i = 0; i < 10; i++) {
User user = new User();
user.setUsername("周子豪 "+i);
user.setClassname("21医学信息工程 "+i);
userList.add(user);
}
model.addAttribute("name","zzh");
model.addAttribute("userList",userList);
return "test.html";
}
}

View File

@ -1,23 +0,0 @@
package com.zzh.springboot.springboot.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class loginController {
@RequestMapping("login")
public String login(){
return "login.html";
}
@RequestMapping("logincommit")
public String logincommit(String username,String password){
if(username.equals("admin")&&password.equals("123456"))
{
return "loginSucess.html";
}
return "loginFail.html";
}
}

View File

@ -1,13 +0,0 @@
package com.zzh.springboot.springboot.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class newsController {
@RequestMapping("news")
public String news(){
return "news.html";
}
}

View File

@ -1,12 +0,0 @@
package com.zzh.springboot.springboot.dao;
import com.zzh.springboot.springboot.model.Person;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface PersonMapper {
public List<Person> getPersons();
public int addPerson(Person person);
}

View File

@ -1,27 +0,0 @@
package com.zzh.springboot.springboot.dao.impl;
import com.zzh.springboot.springboot.dao.PersonMapper;
import com.zzh.springboot.springboot.model.Person;
import com.zzh.springboot.springboot.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class PersonServiceImpl implements PersonService {
@Autowired
private PersonMapper personMapper;
@Override
public List<Person> getPersons() {
return personMapper.getPersons();
}
@Override
public int addPerson(Person person) {
return personMapper.addPerson(person);
}
}

View File

@ -1,10 +0,0 @@
package com.zzh.springboot.springboot.model;
import lombok.Data;
@Data
public class Person {
private String name;
private int age;
private int id;
}

View File

@ -1,10 +0,0 @@
package com.zzh.springboot.springboot.model;
import lombok.Data;
//Data自动生成set get 方法
@Data
public class User {
private String username;
private String classname;
}

View File

@ -1,10 +0,0 @@
package com.zzh.springboot.springboot.service;
import com.zzh.springboot.springboot.model.Person;
import java.util.List;
public interface PersonService {
public List<Person> getPersons();
public int addPerson(Person person);
}

View File

@ -1,10 +0,0 @@
spring.application.name=springboot
spring.web.resources.static-locations=classpath:/img/
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.name=defaultDataSource
spring.datasource.url=jdbc:mysql://106.53.194.250:63306/202101080103?serverTimezone=UTC
spring.datasource.username=202101080103
spring.datasource.password=@hnucm1254
mybatis.mapper-locations=classpath:mapper/*.xml
mybatis.type-aliases-package=com.example.springmybatis.pojo
logging.level.com.example.springmybatis = debug

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zzh.springboot.springboot.dao.PersonMapper">
<select id="getPersons" resultType="com.zzh.springboot.springboot.model.Person">
select * from person;
</select>
<insert id="addPerson" parameterType="com.zzh.springboot.springboot.model.Person">
insert into person(name,age) values(#{name},#{age});
</insert>
</mapper>

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>添加人员页面</h1>
<form th:action="@{/addperson}" method="post">
<input type="text" name="name" placeholder="姓名"><br/>
<input type="text" name="age" placeholder="年龄"><br/>
<input type="submit" value="增加用户"></input>
</input>
</form>
</body>
</html>

View File

@ -1,16 +0,0 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1> 登陆页面 </h1>
<form th:action="@{/logincommit}" method="post">
<input type="text" name="username" placeholder="用户名"><br/>
<input type="password" name="password" placeholder="密码"><br/>
<input type="submit" value="登陆"></input>
</input>
</form>
</body>
</html>

View File

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登陆失败</title>
</head>
<body>
</body>
</html>

View File

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>登陆成功</title>
</head>
<body>
</body>
</html>

View File

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1>新闻页面············</h1>
<div th:text="${newsid}"></div>
<div th:src="123.jpg"></div>
</body>
</html>

View File

@ -1,24 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1> 人员列表</h1>
<a th:href="@{/addpersonpage}">添加人员</a>
<table border="1">
<tr>
<td>id</td>
<td>姓名</td>
<td>年龄</td>
</tr>
<tr th:each="person:${persons}">
<td th:text="${person.id}"></td>
<td th:text="${person.name}"></td>
<td th:text="${person.age}"></td>
</tr>
</table>
</body>
</html>

View File

@ -1,20 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1> hello world</h1>
<table border="1">
<tr>
<td>姓名</td>
<td>班级</td>
</tr>
<tr th:each="user:${userList}">
<td th:text="${user.username}"></td>
<td th:text="${user.classname}"></td>
</tr>
</table>
</body>
</html>

View File

@ -1,13 +0,0 @@
package com.zzh.springboot.springboot;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class SpringbootApplicationTests {
@Test
void contextLoads() {
}
}

View File

@ -8,7 +8,7 @@
<version>3.3.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.zyx.springboot</groupId>
<groupId>com.zzh.springboot</groupId>
<artifactId>task1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>task1</name>

View File

@ -1,40 +0,0 @@
package com.c202101080103.springboot.task1.controller;
import com.c202101080103.springboot.task1.model.Book;
import com.c202101080103.springboot.task1.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
public class bookController {
@Autowired
private BookService bookService;
@ResponseBody
@RequestMapping("getbooks")
public List<Book> getBooks(){
return bookService.getBooks();
}
@RequestMapping("bookList")
public String getBook(Model model){
model.addAttribute("books",bookService.getBooks());
return "bookList.html";
}
@RequestMapping("addbookpage")
public String addBookPage(){
return "addbook.html";
}
@RequestMapping("addbook")
public String addBook(Book book){
bookService.addBook(book);
return "redirect:bookList";
}
}

View File

@ -1,12 +0,0 @@
package com.c202101080103.springboot.task1.dao;
import com.c202101080103.springboot.task1.model.Book;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface BookMapper {
public List<Book> getBooks();
public int addBook(Book book);
}

View File

@ -1,27 +0,0 @@
package com.c202101080103.springboot.task1.dao.impl;
import com.c202101080103.springboot.task1.dao.BookMapper;
import com.c202101080103.springboot.task1.model.Book;
import com.c202101080103.springboot.task1.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class BookServiceImpl implements BookService {
@Autowired
private BookMapper bookMapper;
@Override
public List<Book> getBooks() {
return bookMapper.getBooks();
}
@Override
public int addBook(Book book) {
return bookMapper.addBook(book);
}
}

View File

@ -1,15 +0,0 @@
package com.c202101080103.springboot.task1.model;
import lombok.Data;
import java.util.Date;
@Data
public class Book {
private int id;
private String title;
private String author;
private String isbn;
private String publisher;
private Date published_date;
}

View File

@ -1,10 +0,0 @@
package com.c202101080103.springboot.task1.service;
import com.c202101080103.springboot.task1.model.Book;
import java.util.List;
public interface BookService {
public List<Book> getBooks();
public int addBook(Book book);
}

View File

@ -1,9 +0,0 @@
package com.c202101080103.springboot.task1.service;
import com.c202101080103.springboot.task1.model.User;
public interface UserService {
public int addUser(User user);
public User getUserByUsername(String username);
}

View File

@ -1,4 +1,4 @@
package com.c202101080103.springboot.task1;
package com.zzh202101080103.springboot.task1;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -1,7 +1,7 @@
package com.c202101080103.springboot.task1.controller;
package com.zzh202101080103.springboot.task1.controller;
import com.c202101080103.springboot.task1.model.User;
import com.c202101080103.springboot.task1.service.UserService;
import com.zzh202101080103.springboot.task1.model.User;
import com.zzh202101080103.springboot.task1.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

View File

@ -0,0 +1,141 @@
package com.zzh202101080103.springboot.task1.controller;
import com.zzh202101080103.springboot.task1.model.Book;
import com.zzh202101080103.springboot.task1.model.Borrow;
import com.zzh202101080103.springboot.task1.model.Reviews;
import com.zzh202101080103.springboot.task1.service.BookService;
import com.zzh202101080103.springboot.task1.service.BorrowService;
import com.zzh202101080103.springboot.task1.service.ReviewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
public class bookController {
@Autowired
private BookService bookService;
@Autowired
private ReviewsService reviewsService;
@Autowired
private BorrowService borrowService;
@ResponseBody
@RequestMapping("getbooks")
public List<Book> getBooks(){
return bookService.getBooks();
}
@RequestMapping("bookList")
public String getBook(Model model){
model.addAttribute("books",bookService.getBooks());
return "bookList.html";
}
@RequestMapping("addbookpage")
public String addBookPage(){
return "addbook.html";
}
@RequestMapping("addbook")
public String addBook(Book book){
bookService.addBook(book);
return "redirect:bookList";
}
@RequestMapping("editbook")
public String editBook(int id, Model model) {
Book book = bookService.getBookById(id);
model.addAttribute("book", book);
return "editbook.html";
}
@RequestMapping("updatebook")
public String updateBook(Book book) {
bookService.updateBook(book);
return "redirect:bookList";
}
@RequestMapping("deletebook")
public String deleteBook(int id) {
bookService.deleteBook(id);
return "redirect:bookList";
}
@RequestMapping("viewcomments")
public String viewComments(int id, Model model) {
Book book = bookService.getBookById(id);
List<Reviews> comments = reviewsService.getReviewsById(id);
model.addAttribute("book", book);
model.addAttribute("comments", comments);
return "viewcomments.html"; // 假设视图文件名为 viewcomments.html
}
@RequestMapping("/addcomment")
public String showAddCommentForm(int id, Model model) {
model.addAttribute("id", id);
return "addcomment.html"; // 返回一个用于添加评论的视图
}
@RequestMapping("/savecomment")
public String saveComment(int id, String review,int bookid,int userid) {
Reviews reviews = new Reviews();
reviews.setId(id);
reviews.setBookid(bookid);
reviews.setReview(review);
reviews.setUserid(userid);
reviewsService.addReviews(reviews);
return "redirect:/bookList"; // 重定向到书籍列表页面
}
// 新增书籍借阅
@RequestMapping("addborrow")
public String showAddBorrowForm(Model model) {
return "addborrow.html";
}
@RequestMapping("/saveborrow")
public String saveBorrow(int bookid,int userid,String borrowDate, String returnDate) {
Borrow borrow = new Borrow();
borrow.setBookid(bookid);
borrow.setUserid(userid);
borrow.setBorrowDate(borrowDate);
borrow.setReturnDate(returnDate);
borrowService.addBorrow(borrow);
return "redirect:/borrowList";
}
// 查询书籍借阅
@RequestMapping("borrowList")
public String getBorrowList(Model model) {
List<Borrow> borrows = borrowService.getBorrows();
model.addAttribute("borrows", borrows);
return "borrowList.html";
}
// 编辑书籍借阅
@RequestMapping("editborrow/{id}")
public String editBorrow(@PathVariable int id, Model model) {
Borrow borrow = borrowService.getBorrowById(id);
model.addAttribute("borrow", borrow);
return "editborrow.html";
}
@RequestMapping("/updateborrow")
public String updateBorrow(Borrow borrow) {
borrowService.updateBorrow(borrow);
return "redirect:/borrowList";
}
// 删除书籍借阅
@RequestMapping("deleteborrow/{id}")
public String deleteBorrow(@PathVariable int id) {
borrowService.deleteBorrow(id);
return "redirect:/borrowList";
}
}

View File

@ -1,7 +1,7 @@
package com.c202101080103.springboot.task1.controller;
package com.zzh202101080103.springboot.task1.controller;
import com.c202101080103.springboot.task1.model.User;
import com.c202101080103.springboot.task1.service.UserService;
import com.zzh202101080103.springboot.task1.model.User;
import com.zzh202101080103.springboot.task1.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

View File

@ -0,0 +1,15 @@
package com.zzh202101080103.springboot.task1.dao;
import com.zzh202101080103.springboot.task1.model.Book;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface BookMapper {
public List<Book> getBooks();
public int addBook(Book book);
public int deleteBook(int id);
public Book getBookById(int id);
public int updateBook(Book book);
}

View File

@ -0,0 +1,15 @@
package com.zzh202101080103.springboot.task1.dao;
import com.zzh202101080103.springboot.task1.model.Borrow;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface BorrowMapper {
public int addBorrow(Borrow borrow);
public List<Borrow> getBorrows();
public Borrow getBorrowById(int id);
public int updateBorrow(Borrow borrow);
public int deleteBorrow(int id);
}

View File

@ -0,0 +1,14 @@
package com.zzh202101080103.springboot.task1.dao;
import com.zzh202101080103.springboot.task1.model.Reviews;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface ReviewsMapper {
//添加评论
public int addReviews(Reviews reviews);
//查看评论
public List<Reviews> getReviewsById(int id);
}

View File

@ -1,13 +1,11 @@
package com.c202101080103.springboot.task1.dao;
package com.zzh202101080103.springboot.task1.dao;
import com.c202101080103.springboot.task1.model.User;
import com.zzh202101080103.springboot.task1.model.User;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface UserMapper {
public User getUserByUsername(String username);
public int addUser(User user);
public User getUserById(int id);
}

View File

@ -0,0 +1,18 @@
package com.zzh202101080103.springboot.task1.model;
import lombok.Data;
import java.time.LocalDate;
import java.util.List;
@Data
public class Book {
private int id;
private String title;
private String author;
private String isbn;
private String publisher;
private LocalDate published_date;
private List<Reviews> reviewsList;
}

View File

@ -0,0 +1,12 @@
package com.zzh202101080103.springboot.task1.model;
import lombok.Data;
@Data
public class Borrow {
private int id;
private int bookid;
private int userid;
private String borrowDate;
private String returnDate;
}

View File

@ -0,0 +1,14 @@
package com.zzh202101080103.springboot.task1.model;
import lombok.Data;
@Data
public class Reviews {
private int id;
private int bookid;
private int userid;
private String review;
private Book book;
private User user;
}

View File

@ -1,4 +1,4 @@
package com.c202101080103.springboot.task1.model;
package com.zzh202101080103.springboot.task1.model;
import lombok.Data;
//Data自动生成set get 方法

View File

@ -0,0 +1,13 @@
package com.zzh202101080103.springboot.task1.service;
import com.zzh202101080103.springboot.task1.model.Book;
import java.util.List;
public interface BookService {
public List<Book> getBooks();
public int addBook(Book book);
public int deleteBook(int id);
public Book getBookById(int id);
public int updateBook(Book book);
}

View File

@ -0,0 +1,13 @@
package com.zzh202101080103.springboot.task1.service;
import com.zzh202101080103.springboot.task1.model.Borrow;
import java.util.List;
public interface BorrowService {
public int addBorrow(Borrow borrow);
public List<Borrow> getBorrows();
public Borrow getBorrowById(int id);
public int updateBorrow(Borrow borrow);
public int deleteBorrow(int id);
}

View File

@ -0,0 +1,12 @@
package com.zzh202101080103.springboot.task1.service;
import com.zzh202101080103.springboot.task1.model.Reviews;
import java.util.List;
public interface ReviewsService {
//添加评论
public int addReviews(Reviews reviews);
//查看评论
public List<Reviews> getReviewsById(int id);
}

View File

@ -0,0 +1,10 @@
package com.zzh202101080103.springboot.task1.service;
import com.zzh202101080103.springboot.task1.model.User;
public interface UserService {
public int addUser(User user);
public User getUserByUsername(String username);
public User getUserById(int id);
}

View File

@ -0,0 +1,43 @@
package com.zzh202101080103.springboot.task1.service.impl;
import com.zzh202101080103.springboot.task1.dao.BookMapper;
import com.zzh202101080103.springboot.task1.model.Book;
import com.zzh202101080103.springboot.task1.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class BookServiceImpl implements BookService {
@Autowired
private BookMapper bookMapper;
@Override
public List<Book> getBooks() {
return bookMapper.getBooks();
}
@Override
public int addBook(Book book) {
return bookMapper.addBook(book);
}
@Override
public int deleteBook(int id) {
return bookMapper.deleteBook(id);
}
@Override
public Book getBookById(int id) {
return bookMapper.getBookById(id);
}
@Override
public int updateBook(Book book) {
return bookMapper.updateBook(book);
}
}

View File

@ -0,0 +1,41 @@
package com.zzh202101080103.springboot.task1.service.impl;
import com.zzh202101080103.springboot.task1.dao.BorrowMapper;
import com.zzh202101080103.springboot.task1.model.Borrow;
import com.zzh202101080103.springboot.task1.service.BorrowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class BorrowServiceImpl implements BorrowService {
@Autowired
private BorrowMapper borrowMapper;
@Override
public int addBorrow(Borrow borrow) {
return borrowMapper.addBorrow(borrow);
}
@Override
public List<Borrow> getBorrows() {
return borrowMapper.getBorrows();
}
@Override
public Borrow getBorrowById(int id) {
return borrowMapper.getBorrowById(id);
}
@Override
public int updateBorrow(Borrow borrow) {
return borrowMapper.updateBorrow(borrow);
}
@Override
public int deleteBorrow(int id) {
return borrowMapper.deleteBorrow(id);
}
}

View File

@ -0,0 +1,26 @@
package com.zzh202101080103.springboot.task1.service.impl;
import com.zzh202101080103.springboot.task1.dao.ReviewsMapper;
import com.zzh202101080103.springboot.task1.model.Reviews;
import com.zzh202101080103.springboot.task1.service.ReviewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ReviewsServiceImpl implements ReviewsService {
@Autowired
private ReviewsMapper reviewsMapper;
@Override
public int addReviews(Reviews reviews) {
return reviewsMapper.addReviews(reviews);
}
@Override
public List<Reviews> getReviewsById(int id) {
return reviewsMapper.getReviewsById(id);
}
}

View File

@ -1,8 +1,8 @@
package com.c202101080103.springboot.task1.dao.impl;
package com.zzh202101080103.springboot.task1.service.impl;
import com.c202101080103.springboot.task1.dao.UserMapper;
import com.c202101080103.springboot.task1.model.User;
import com.c202101080103.springboot.task1.service.UserService;
import com.zzh202101080103.springboot.task1.dao.UserMapper;
import com.zzh202101080103.springboot.task1.model.User;
import com.zzh202101080103.springboot.task1.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -15,4 +15,9 @@ public class UserServiceImpl implements UserService{
@Override
public User getUserByUsername(String username){return userMapper.getUserByUsername(username);}
@Override
public User getUserById(int id) {
return userMapper.getUserById(id);
}
}

View File

@ -1,12 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.c202101080103.springboot.task1.dao.BookMapper">
<select id="getBooks" resultType="com.c202101080103.springboot.task1.model.Book">
<mapper namespace="com.zzh202101080103.springboot.task1.dao.BookMapper">
<select id="getBooks" resultType="com.zzh202101080103.springboot.task1.model.Book">
select * from books202101080103;
</select>
<insert id="addBook" parameterType="com.c202101080103.springboot.task1.model.Book">
<insert id="addBook" parameterType="com.zzh202101080103.springboot.task1.model.Book">
insert into books202101080103(title,author,isbn,publisher,published_date)
values(#{title},#{author},#{isbn},#{publisher},#{published_date});
</insert>
<delete id="deleteBook" parameterType="int">
delete from books202101080103 where id=#{id};
</delete>
<select id="getBookById" resultType="com.zzh202101080103.springboot.task1.model.Book">
select * from books202101080103 where id=#{id};
</select>
<update id="updateBook" parameterType="com.zzh202101080103.springboot.task1.model.Book">
update books202101080103 set title=#{title},author=#{author},isbn=#{isbn},publisher=#{publisher},published_date=#{published_date} where id=#{id};
</update>
</mapper>

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zzh202101080103.springboot.task1.dao.BorrowMapper">
<!-- 添加借阅记录 -->
<insert id="addBorrow" parameterType="com.zzh202101080103.springboot.task1.model.Borrow">
INSERT INTO borrow_records20220108013 (userid, bookid, borrowDate, returnDate)
VALUES (#{userid}, #{bookid}, #{borrowDate}, #{returnDate})
</insert>
<!-- 获取所有借阅记录 -->
<select id="getBorrows" resultType="com.zzh202101080103.springboot.task1.model.Borrow">
SELECT * FROM borrow_records20220108013
</select>
<!-- 根据 ID 获取借阅记录 -->
<select id="getBorrowById" parameterType="int" resultType="com.zzh202101080103.springboot.task1.model.Borrow">
SELECT * FROM borrow_records20220108013 WHERE id = #{id}
</select>
<!-- 更新借阅记录 -->
<update id="updateBorrow" parameterType="com.zzh202101080103.springboot.task1.model.Borrow">
UPDATE borrow_records20220108013
SET userid = #{userid},
bookid = #{bookid},
borrowDate = #{borrowDate},
returnDate = #{returnDate}
WHERE id = #{id}
</update>
<!-- 删除借阅记录 -->
<delete id="deleteBorrow" parameterType="int">
DELETE FROM borrow_records20220108013 WHERE id = #{id}
</delete>
</mapper>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zzh202101080103.springboot.task1.dao.ReviewsMapper">
<select id="getReviewsById" resultMap="ReviewMap1">
select * from reviews202101080103 where bookid=#{bookid};
</select>
<resultMap id="ReviewMap1" type="com.zzh202101080103.springboot.task1.model.Reviews">
<id column="id" property="id"/>
<result column="review" property="review"/>
<association property="user"
column="userid"
select="com.zzh202101080103.springboot.task1.dao.UserMapper.getUserById"
javaType="com.zzh202101080103.springboot.task1.model.User">
</association>
<association property="book"
column="bookid"
select="com.zzh202101080103.springboot.task1.dao.BookMapper.getBookById"
javaType="com.zzh202101080103.springboot.task1.model.Book">
</association>
</resultMap>
<insert id="addReviews" parameterType="com.zzh202101080103.springboot.task1.model.Reviews">
insert into reviews202101080103(review,bookid,userid) values(#{review},#{bookid},#{userid});
</insert>
</mapper>

View File

@ -1,14 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.c202101080103.springboot.task1.dao.UserMapper">
<mapper namespace="com.zzh202101080103.springboot.task1.dao.UserMapper">
<!-- 查询用户 -->
<select id="getUserByUsername" parameterType="string" resultType="com.c202101080103.springboot.task1.model.User">
<select id="getUserByUsername" parameterType="string" resultType="com.zzh202101080103.springboot.task1.model.User">
SELECT * FROM users202101080103 WHERE username = #{username}
</select>
<select id="getUserById" resultType="com.zzh202101080103.springboot.task1.model.User">
select * from users202101080103 where id = #{id}
</select>
<!-- 添加用户 -->
<insert id="addUser" parameterType="com.c202101080103.springboot.task1.model.User">
<insert id="addUser" parameterType="com.zzh202101080103.springboot.task1.model.User">
INSERT INTO users202101080103 (username, password)
VALUES (#{username}, #{password})
</insert>

View File

@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Add Borrow</title>
<style>
.form-group {
margin-bottom: 10px;
}
label {
display: block;
margin-bottom: 5px;
}
</style>
</head>
<body>
<h1>增加借阅信息</h1>
<form action="#" th:action="@{/saveborrow}" method="post">
<div class="form-group">
<label for="bookid">Book ID:</label>
<input type="text" name="bookid" id="bookid"/>
</div>
<div class="form-group">
<label for="userid">User ID:</label>
<input type="text" name="userid" id="userid"/>
</div>
<div class="form-group">
<label for="borrowDate">Borrow Date:</label>
<input type="datetime-local" name="borrowDate" id="borrowDate"/>
</div>
<div class="form-group">
<label for="returnDate">Return Date:</label>
<input type="date" name="returnDate" id="returnDate"/>
</div>
<button type="submit">Save</button>
</form>
</body>
</html>

View File

@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>添加评论</title>
<style>
.form-group {
margin-bottom: 10px;
}
label {
display: block;
margin-bottom: 5px;
}
</style>
</head>
<body>
<h1>添加评论</h1>
<form action="#" th:action="@{/savecomment}" method="post">
<div class="form-group">
<label for="id">评论</label>
<input type="text" name="id" id="id" th:value="${id}" readonly/>
</div>
<div class="form-group">
<label for="bookid">书籍 ID:</label>
<input type="text" name="bookid" id="bookid" th:value="${id}" readonly/>
</div>
<div class="form-group">
<label for="userid">用户 ID:</label>
<input type="text" name="userid" id="userid" th:value="1" readonly/>
</div>
<div class="form-group">
<label for="review">评论内容:</label>
<textarea name="review" id="review" rows="3" cols="50"></textarea>
</div>
<br/>
<button type="submit">提交</button>
</form>
</body>
</html>

View File

@ -1,21 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<meta charset="UTF-8">
<title>书籍列表</title>
</head>
<body>
<h1> 书籍列表</h1>
<h1>书籍列表</h1>
<a th:href="@{/addbookpage}">添加书籍</a>
<a th:href="@{/borrowList}">查看借阅信息</a>
<table border="1">
<tr>
<td>id</td>
<td>书名</td>
<td>作者</td>
<td>isbn</td>
<td>出版社</td>
<td>出版日期</td>
<th>ID</th>
<th>书名</th>
<th>作者</th>
<th>ISBN</th>
<th>出版社</th>
<th>出版日期</th>
<th>操作</th>
</tr>
<tr th:each="book:${books}">
<td th:text="${book.id}"></td>
@ -24,7 +26,13 @@
<td th:text="${book.isbn}"></td>
<td th:text="${book.publisher}"></td>
<td th:text="${book.published_date}"></td>
<td>
<a th:href="@{/editbook(id=${book.id})}">修改</a>
<a th:href="@{/deletebook(id=${book.id})}">删除</a>
<a th:href="@{/viewcomments(id=${book.id})}">查看评论</a>
<a th:href="@{/addcomment(id=${book.id})}">添加评论</a>
</td>
</tr>
</table>
</body>
</html>
</html>

View File

@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Borrow List</title>
<style>
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #f2f2f2;
}
a {
text-decoration: none;
color: blue;
}
</style>
</head>
<body>
<h1>借阅信息</h1>
<a href="/addborrow">新增借阅信息</a>
<table>
<thead>
<tr>
<th>ID</th>
<th>Book ID</th>
<th>User ID</th>
<th>Borrow Date</th>
<th>Return Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr th:each="borrow : ${borrows}">
<td th:text="${borrow.id}"></td>
<td th:text="${borrow.bookid}"></td>
<td th:text="${borrow.userid}"></td>
<td th:text="${borrow.borrowDate}"></td>
<td th:text="${borrow.returnDate}"></td>
<td>
<a th:href="@{/editborrow/{id}(id=${borrow.id})}">Edit</a> |
<a th:href="@{/deleteborrow/{id}(id=${borrow.id})}">Delete</a>
</td>
</tr>
</tbody>
</table>
</body>
</html>

View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>编辑书籍</title>
</head>
<body>
<h1>编辑书籍</h1>
<form action="/updatebook" method="post">
<label for="id">ID:</label>
<input type="text" id="id" name="id" th:value="${book.id}" readonly><br><br>
<label for="title">书名:</label>
<input type="text" id="title" name="title" th:value="${book.title}"><br><br>
<label for="author">作者:</label>
<input type="text" id="author" name="author" th:value="${book.author}"><br><br>
<label for="isbn">ISBN:</label>
<input type="text" id="isbn" name="isbn" th:value="${book.isbn}"><br><br>
<label for="publisher">出版社:</label>
<input type="text" id="publisher" name="publisher" th:value="${book.publisher}"><br><br>
<label for="published_date">出版日期:</label>
<input type="date" id="published_date" name="published_date" th:value="${book.published_date}"><br><br>
<button type="submit">保存</button>
</form>
<a href="/bookList">返回书籍列表</a>
</body>
</html>

View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Edit Borrow</title>
<style>
.form-group {
margin-bottom: 10px;
}
label {
display: block;
margin-bottom: 5px;
}
</style>
</head>
<body>
<h1>修改借阅信息</h1>
<form action="#" th:action="@{/updateborrow}" method="post">
<input type="hidden" name="id" th:value="${borrow.id}"/>
<div class="form-group">
<label for="bookid">Book ID:</label>
<input type="text" name="bookid" id="bookid" th:value="${borrow.bookid}"/>
</div>
<div class="form-group">
<label for="userid">User ID:</label>
<input type="text" name="userid" id="userid" th:value="${borrow.userid}"/>
</div>
<div class="form-group">
<label for="borrowDate">Borrow Date:</label>
<input type="text" name="borrowDate" id="borrowDate" th:value="${borrow.borrowDate}"/>
</div>
<div class="form-group">
<label for="returnDate">Return Date:</label>
<input type="text" name="returnDate" id="returnDate" th:value="${borrow.returnDate}"/>
</div>
<button type="submit">Update</button>
</form>
</body>
</html>

View File

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>查看书籍评论</title>
</head>
<body>
<h1>查看书籍评论</h1>
<h2>书籍信息</h2>
<div>
<p><strong>ID:</strong> <span th:text="${book.id}"></span></p>
<p><strong>书名:</strong> <span th:text="${book.title}"></span></p>
<p><strong>作者:</strong> <span th:text="${book.author}"></span></p>
<p><strong>ISBN:</strong> <span th:text="${book.isbn}"></span></p>
<p><strong>出版社:</strong> <span th:text="${book.publisher}"></span></p>
<p><strong>出版日期:</strong> <span th:text="${book.published_date}"></span></p>
</div>
<h2>评论列表</h2>
<table border="1">
<tr>
<th>ID</th>
<th>评论内容</th>
<th>评论者</th>
</tr>
<tr th:each="comment:${comments}">
<td th:text="${comment.id}"></td>
<td th:text="${comment.review}"></td>
<td th:text="${comment.user.username}"></td>
</tr>
</table>
<a th:href="@{/bookList}">返回书籍列表</a>
</body>
</html>

View File

@ -1,4 +1,4 @@
package com.c202101080103.springboot.task1;
package com.zzh202101080103.springboot.task1;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;