This commit is contained in:
awin-x 2025-02-23 11:01:25 +08:00
parent 7f009488c7
commit 45d462b02f
66 changed files with 1119 additions and 103 deletions

View File

@ -0,0 +1,69 @@
<component name="ArtifactManager">
<artifact type="exploded-war" name="test05:war exploded">
<output-path>$PROJECT_DIR$/out/artifacts/test05_war_exploded</output-path>
<root id="root">
<element id="directory" name="WEB-INF">
<element id="directory" name="classes">
<element id="module-output" name="test05" />
</element>
<element id="directory" name="lib">
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-web:3.4.0" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter:3.4.0" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot:3.4.0" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-logging:3.4.0" />
<element id="library" level="project" name="Maven: ch.qos.logback:logback-classic:1.5.12" />
<element id="library" level="project" name="Maven: ch.qos.logback:logback-core:1.5.12" />
<element id="library" level="project" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.24.1" />
<element id="library" level="project" name="Maven: org.apache.logging.log4j:log4j-api:2.24.1" />
<element id="library" level="project" name="Maven: org.slf4j:jul-to-slf4j:2.0.16" />
<element id="library" level="project" name="Maven: jakarta.annotation:jakarta.annotation-api:2.1.1" />
<element id="library" level="project" name="Maven: org.yaml:snakeyaml:2.3" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-json:3.4.0" />
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.18.1" />
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.18.1" />
<element id="library" level="project" name="Maven: com.fasterxml.jackson.core:jackson-core:2.18.1" />
<element id="library" level="project" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.1" />
<element id="library" level="project" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.1" />
<element id="library" level="project" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.18.1" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:3.4.0" />
<element id="library" level="project" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:10.1.33" />
<element id="library" level="project" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:10.1.33" />
<element id="library" level="project" name="Maven: org.springframework:spring-web:6.2.0" />
<element id="library" level="project" name="Maven: org.springframework:spring-beans:6.2.0" />
<element id="library" level="project" name="Maven: io.micrometer:micrometer-observation:1.14.1" />
<element id="library" level="project" name="Maven: io.micrometer:micrometer-commons:1.14.1" />
<element id="library" level="project" name="Maven: org.springframework:spring-webmvc:6.2.0" />
<element id="library" level="project" name="Maven: org.springframework:spring-context:6.2.0" />
<element id="library" level="project" name="Maven: org.springframework:spring-expression:6.2.0" />
<element id="library" level="project" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.4" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:3.4.0" />
<element id="library" level="project" name="Maven: com.zaxxer:HikariCP:5.1.0" />
<element id="library" level="project" name="Maven: org.springframework:spring-jdbc:6.2.0" />
<element id="library" level="project" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:3.0.4" />
<element id="library" level="project" name="Maven: org.mybatis:mybatis:3.5.17" />
<element id="library" level="project" name="Maven: org.mybatis:mybatis-spring:3.0.4" />
<element id="library" level="project" name="Maven: org.springframework:spring-core:6.2.0" />
<element id="library" level="project" name="Maven: org.springframework:spring-jcl:6.2.0" />
<element id="library" level="project" name="Maven: org.springframework:spring-tx:6.2.0" />
<element id="library" level="project" name="Maven: com.alibaba:druid-spring-boot-3-starter:1.2.24" />
<element id="library" level="project" name="Maven: com.alibaba:druid:1.2.24" />
<element id="library" level="project" name="Maven: org.slf4j:slf4j-api:2.0.16" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-autoconfigure:3.4.0" />
<element id="library" level="project" name="Maven: org.xerial:sqlite-jdbc:3.47.1.0" />
<element id="library" level="project" name="Maven: com.mysql:mysql-connector-j:8.0.33" />
<element id="library" level="project" name="Maven: org.projectlombok:lombok:1.18.36" />
<element id="library" level="project" name="Maven: io.jsonwebtoken:jjwt:0.12.3" />
<element id="library" level="project" name="Maven: io.jsonwebtoken:jjwt-api:0.12.3" />
<element id="library" level="project" name="Maven: io.jsonwebtoken:jjwt-impl:0.12.3" />
<element id="library" level="project" name="Maven: io.jsonwebtoken:jjwt-jackson:0.12.3" />
<element id="library" level="project" name="Maven: com.alibaba.fastjson2:fastjson2:2.0.53" />
<element id="library" level="project" name="Maven: org.springframework.boot:spring-boot-starter-aop:3.4.0" />
<element id="library" level="project" name="Maven: org.springframework:spring-aop:6.2.0" />
<element id="library" level="project" name="Maven: org.aspectj:aspectjweaver:1.9.22.1" />
<element id="library" level="project" name="Maven: org.realityforge.org.jetbrains.annotations:org.jetbrains.annotations:1.7.0" />
</element>
</element>
<element id="javaee-facet-resources" facet="test05/web/Web" />
</root>
</artifact>
</component>

View File

@ -15,6 +15,7 @@
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" /> <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" /> <outputRelativeToContentRoot value="true" />
<module name="test05" /> <module name="test05" />
<module name="stuTest" />
</profile> </profile>
</annotationProcessing> </annotationProcessing>
<bytecodeTargetLevel target="21"> <bytecodeTargetLevel target="21">
@ -24,6 +25,7 @@
<component name="JavacSettings"> <component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE"> <option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="learn03-springboot" options="-parameters" /> <module name="learn03-springboot" options="-parameters" />
<module name="stuTest" options="-parameters" />
<module name="test05" options="-parameters" /> <module name="test05" options="-parameters" />
</option> </option>
</component> </component>

View File

@ -15,16 +15,6 @@
</jdbc-additional-properties> </jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir> <working-dir>$ProjectFileDir$</working-dir>
</data-source> </data-source>
<data-source source="LOCAL" name="db_student.db" uuid="13372887-38a4-4cb1-88a7-cb74208ae924">
<driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/../../database/学习/java测试数据库/db_student.db</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
<data-source source="LOCAL" name="db_student" uuid="e52053d6-7a76-429a-af2f-d7d197f5a15d"> <data-source source="LOCAL" name="db_student" uuid="e52053d6-7a76-429a-af2f-d7d197f5a15d">
<driver-ref>sqlite.xerial</driver-ref> <driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize> <synchronize>true</synchronize>
@ -40,5 +30,18 @@
</library> </library>
</libraries> </libraries>
</data-source> </data-source>
<data-source source="LOCAL" name="金开" uuid="26679e7a-b0e0-4d19-bf92-65e41dadde7f">
<driver-ref>mariadb</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mariadb://www.awin-x.top:63306</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>
</component> </component>
</project> </project>

View File

@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="Encoding" native2AsciiForPropertiesFiles="true" defaultCharsetForPropertiesFiles="GBK"> <component name="Encoding" native2AsciiForPropertiesFiles="true" defaultCharsetForPropertiesFiles="GBK">
<file url="file://$PROJECT_DIR$/homework02/stuTest/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/learn02/web/js/course-edit.js" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/learn02/web/js/course-edit.js" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/learn02/web/js/index.js" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/learn02/web/js/index.js" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/learn1/web/js/course-edit.js" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/learn1/web/js/course-edit.js" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/learn1/web/js/index.js" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/learn1/web/js/index.js" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/stuTest/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/test05/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/test05/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/test05/src/main/java/test05/mapper/CourseMapper.java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/test05/src/main/java/test05/mapper/CourseMapper.java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/test05/src/test/java/test05/Test05ApplicationTests.java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/test05/src/test/java/test05/Test05ApplicationTests.java" charset="UTF-8" />

View File

@ -1,11 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$/stuTest" />
</component>
<component name="MavenProjectsManager"> <component name="MavenProjectsManager">
<option name="originalFiles"> <option name="originalFiles">
<list> <list>
<option value="$PROJECT_DIR$/learn03/pom.xml" /> <option value="$PROJECT_DIR$/learn03/pom.xml" />
<option value="$PROJECT_DIR$/test05/pom.xml" /> <option value="$PROJECT_DIR$/test05/pom.xml" />
<option value="$PROJECT_DIR$/homework02/stuTest/pom.xml" />
<option value="$PROJECT_DIR$/stuTest/pom.xml" />
</list> </list>
</option> </option>
</component> </component>

Binary file not shown.

View File

@ -17,6 +17,10 @@
<ul class="nav-list"> <ul class="nav-list">
<li class="nav-item"><a href="${pageContext.request.contextPath}/home.jsp" target="content">欢迎页</a></li> <li class="nav-item"><a href="${pageContext.request.contextPath}/home.jsp" target="content">欢迎页</a></li>
<li class="nav-item"><a href="${pageContext.request.contextPath}/course/course.jsp" target="content">课程列表</a></li> <li class="nav-item"><a href="${pageContext.request.contextPath}/course/course.jsp" target="content">课程列表</a></li>
<% int a=10; %>
<%! int b=1;%>
<% out.print(a);a=a+1;out.print(b);b=b+1; %>
</ul> </ul>
</div> </div>
<iframe src="${pageContext.request.contextPath}/home.jsp" class="content" name="content" height="100%" width="100%"></iframe> <iframe src="${pageContext.request.contextPath}/home.jsp" class="content" name="content" height="100%" width="100%"></iframe>

11
learn1/web/test.jsp Normal file
View File

@ -0,0 +1,11 @@
<%@ page import="java.util.Date" %><%--
Created by IntelliJ IDEA.
User: awinx
Date: 2025/1/10
Time: 下午12:40
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<p>
今天的日期是: <%= (new Date()).toString()%>
</p>

2
stuTest/.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
/mvnw text eol=lf
*.cmd text eol=crlf

33
stuTest/.gitignore vendored Normal file
View File

@ -0,0 +1,33 @@
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

@ -0,0 +1,19 @@
# 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
#
# http://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.9/apache-maven-3.9.9-bin.zip

259
stuTest/mvnw vendored Normal file
View File

@ -0,0 +1,259 @@
#!/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
#
# http://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 "$@"

149
stuTest/mvnw.cmd vendored Normal file
View File

@ -0,0 +1,149 @@
<# : 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 http://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"

77
stuTest/pom.xml Normal file
View File

@ -0,0 +1,77 @@
<?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.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>top.awin-x</groupId>
<artifactId>stuTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>stuTest</name>
<description>stuTest</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>21</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.36</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter-test</artifactId>
<version>3.0.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,13 @@
package stuTest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Test5Application {
public static void main(String[] args) {
SpringApplication.run(Test5Application.class, args);
}
}

View File

@ -0,0 +1,51 @@
package stuTest.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import stuTest.pojo.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import stuTest.pojo.Student;
import stuTest.service.StudentService;
@RestController
@RequestMapping("/StudentAction")
@CrossOrigin(maxAge = 3600)
public class StudentController {
@Autowired
StudentService studentService;
@RequestMapping("/get")
@CrossOrigin(maxAge = 3600)
public Result getStudent(String name) {
if (name == null) {
return Result.fail(null);
}
return studentService.selectStudent(name);
}
@RequestMapping("/add")
@CrossOrigin(maxAge = 3600)
public Result addStudent(Student student) {
if (student == null) {
return Result.fail(null);
}
return studentService.insertStudent(student);
}
@RequestMapping("/del")
@CrossOrigin(maxAge = 3600)
public Result deleteStudent(int id) {
return studentService.deleteStudent(id);
}
@RequestMapping("/upd")
@CrossOrigin(maxAge = 3600)
public Result updateStudent(Student student) {
if (student == null) {
return Result.fail(null);
}
return studentService.updateStudent(student);
}
}

View File

@ -0,0 +1,14 @@
package stuTest.mapper;
import org.apache.ibatis.annotations.Mapper;
import stuTest.pojo.Student;
import java.util.List;
@Mapper
public interface StudentMapper {
List<Student> selectStudent(String name);
int insertStudent(Student student);
int deleteStudent(int id);
int updateStudent(Student student);
}

View File

@ -0,0 +1,21 @@
package stuTest.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
boolean success;
String message;
Object data;
public static Result success(Object data) {
return new Result(true, "success", data);
}
public static Result fail(String message) {
return new Result(false, message, null);
}
}

View File

@ -0,0 +1,19 @@
package stuTest.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Student {
private int id=-1;
private String code="";
private String name="";
private int sex=-1;
private int grade=-1;
private int major=-1;
private String detail="";
}

View File

@ -0,0 +1,52 @@
package stuTest.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import stuTest.mapper.StudentMapper;
import stuTest.pojo.Result;
import stuTest.pojo.Student;
@Component
public class StudentService {
@Autowired
StudentMapper studentMapper;
public Result selectStudent(String name)
{
return Result.success(studentMapper.selectStudent(name));
}
public Result insertStudent(Student student)
{
if(student.getCode().isEmpty()||student.getName().isEmpty()||student.getMajor()==-1||student.getGrade()==-1||student.getSex()==-1){
return Result.fail("invalid data");
}
int result = studentMapper.insertStudent(student);
if (result == 1){
return Result.success(student);
}else{
return Result.fail("insert failed");
}
}
public Result deleteStudent(int id)
{
int result = studentMapper.deleteStudent(id);
if (result == 1){
return Result.success(id);
}
return Result.fail("delete failed");
}
public Result updateStudent(Student student)
{
if(student.getCode().isEmpty()||student.getName().isEmpty()||student.getMajor()==-1||student.getGrade()==-1||student.getSex()==-1){
return Result.fail("invalid data");
}
int result = studentMapper.updateStudent(student);
if (result == 1){
return Result.success(student);
}
return Result.fail("update failed");
}
}

View File

@ -0,0 +1,7 @@
spring.application.name=stuTest
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://www.awin-x.top:3306/db_student
spring.datasource.username=root
spring.datasource.password=123456
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1 @@
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>stu</title><script defer="defer" src="/js/chunk-vendors.60f33805.js"></script><script defer="defer" src="/js/app.d8291e48.js"></script><link href="/css/app.1625914d.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but stu doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,37 @@
<?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="stuTest.mapper.StudentMapper">
<select id="selectStudent" resultType="stuTest.pojo.Student">
select N_STUDENT_ID as id ,
VC_STUDENT_CODE as code,
VC_STUDENT_NAME as name,
N_SEX as sex,
N_GRADE as grade,
N_MAJOR as major,
VC_DETAIL as detaile
from t_student
where upper(VC_STUDENT_NAME) like concat("%",upper(#{name}),"%");
</select>
<insert id="insertStudent" keyProperty="id" useGeneratedKeys="true">
insert into t_student (VC_STUDENT_CODE,VC_STUDENT_NAME,N_SEX,N_GRADE,N_MAJOR,VC_DETAIL)
values (#{code},#{name},#{sex},#{grade},#{major},#{detail});
</insert>
<delete id="deleteStudent">
delete from t_student
where N_STUDENT_ID=#{id};
</delete>
<update id="updateStudent">
update t_student set VC_STUDENT_CODE=#{code},
VC_STUDENT_NAME=#{name},
N_SEX=#{sex},
N_GRADE=#{grade},
N_MAJOR=#{major},
VC_DETAIL=#{detail}
where N_STUDENT_ID=#{id};
</update>
</mapper>

9
test05/WEB-INF/web.xml Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
version="6.0">
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>

View File

@ -29,6 +29,11 @@
<properties> <properties>
<java.version>21</java.version> <java.version>21</java.version>
</properties> </properties>
<!-- 使用外置tomcat -->
<!-- <packaging>war</packaging>-->
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -100,6 +105,19 @@
<version>1.7.0</version> <version>1.7.0</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-web</artifactId>-->
<!-- &lt;!&ndash;移除tomcat依赖&ndash;&gt;-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-tomcat</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
</dependencies> </dependencies>
<build> <build>

View File

@ -2,11 +2,17 @@ package test05;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication @SpringBootApplication
public class Test05Application { public class Test05Application extends SpringBootServletInitializer {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(Test05Application.class, args); SpringApplication.run(Test05Application.class, args);
} }
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Test05Application.class);
}
} }

View File

@ -10,59 +10,83 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Objects;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
@Component //@Component
public class DatabaseConfig { public class DatabaseConfig {
// @Autowired 可以注入bean // @Autowired 可以注入bean
// ISysUserService userService; // ISysUserService userService;
DruidDataSource ds; DruidDataSource ds;
Boolean input = false;
@Autowired @Autowired
DatabaseConfig(DruidDataSource ds) { DatabaseConfig(DruidDataSource ds) {
this.ds = ds; this.ds = ds;
} }
@PostConstruct @PostConstruct
public void init() throws InterruptedException, IOException, SQLException { public void init() {
//启动时输入数据库连接地址 Thread inputThread = new Thread(() -> {
// BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); try {
// System.out.println("请输入数据库连接地址"); System.out.println(System.getProperty("user.dir"));
// String buf = br.readLine(); String workingDir = System.getProperty("user.dir");
// System.out.println(buf); if (new File(workingDir+"\\db_student.db").exists()) {
// ds.setUrl(buf); ds.restart();
// buf = br.readLine();
// ds.setUsername(buf);
// buf = br.readLine();
// ds.setPassword(buf);
System.out.println(System.getProperty("user.dir"));
String workingDir = System.getProperty("user.dir");
if (new File(workingDir+"\\db_student.db").exists()) {
ds.restart();
ds.setDriverClassName("org.sqlite.JDBC");
ds.setUrl("jdbc:sqlite:"+workingDir+"\\db_student.db");
System.out.println("使用外部数据库文件!");
}else{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("请选择数据库1mysql2sqlite");
int type = Integer.parseInt(br.readLine());
switch (type) {
case 1:
ds.setDriverClassName("com.mysql.jdbc.Driver");
System.out.println("请输入数据库url仅地址,留空使用localhost:3306");
String url= br.readLine();
ds.setUrl("jdbc:mysql:"+(url.isEmpty()?"localhost:3306":url)+(url.endsWith("/")?"":"/")+"db_student");
System.out.println("请输入用户名:");
String username=br.readLine();
ds.setUsername(username);
System.out.println("请输入密码:");
String password=br.readLine();
ds.setPassword(password);
case 2:
System.out.println("使用内嵌测试数据,修改将不会被保存!");
ds.setDriverClassName("org.sqlite.JDBC"); ds.setDriverClassName("org.sqlite.JDBC");
ds.setUrl("jdbc:sqlite::resource:db/db_student.db"); ds.setUrl("jdbc:sqlite:"+workingDir+"\\db_student.db");
System.out.println("使用外部数据库文件!");
}else{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("请选择数据库1mysql2sqlite");
this.input = true;
int type = 0;
try {
type = Integer.parseInt(br.readLine());
} catch (NumberFormatException | NullPointerException e) {
System.out.println("将会使用内部部数据库文件!");
return;
}
switch (type) {
case 1:
System.out.println("请输入数据库url仅地址,留空使用localhost:3306");
String url= br.readLine();
System.out.println("请输入用户名:");
String username=br.readLine();
System.out.println("请输入密码:");
String password=br.readLine();
ds.restart();
ds.setUsername(username);
ds.setPassword(password);
ds.setUrl("jdbc:mysql:"+(url.isEmpty()?"localhost:3306":url)+(url.endsWith("/")?"":"/")+"db_student");
ds.setDriverClassName("com.mysql.jdbc.Driver");
case 2:
System.out.println("使用内嵌测试数据,修改将不会被保存!");
ds.setDriverClassName("org.sqlite.JDBC");
ds.setUrl("jdbc:sqlite::resource:db/db_student.db");
}
}
} catch (IOException | SQLException e) {
throw new RuntimeException(e);
} }
});
inputThread.start();
try {
inputThread.join(10000); // 等待10秒
if (inputThread.isAlive() && !input) {
// 如果10秒后线程还活着说明没有输入
inputThread.interrupt();
System.out.println("未配置数据库");
return;
}
} catch (InterruptedException e) {
return ;
} finally {
inputThread.interrupt();
} }
} }
} }

View File

@ -3,8 +3,10 @@ package test05.controller;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import test05.pojo.Course;
import test05.pojo.Result; import test05.pojo.Result;
import test05.pojo.Score; import test05.pojo.Score;
import test05.pojo.Student;
import test05.service.ScoreService; import test05.service.ScoreService;
@RestController @RestController
@ -16,19 +18,25 @@ public class ScoreController {
this.scoreService = scoreService; this.scoreService = scoreService;
} }
@RequestMapping("/get") @RequestMapping("/get")
public Result getScore(Score score) { public Result getScore(int studentId, int courseId) {
return scoreService.getScore(score); return scoreService.getScore(new Student(studentId), new Course(courseId));
} }
@RequestMapping("/update") @RequestMapping("/update")
public Result updateScore(Score score) { public Result updateScore(Score score) {
return scoreService.updateScore(score); return scoreService.updateScore(score);
} }
@RequestMapping("add") @RequestMapping("add")
public Result addScore(Score score) { public Result addScore(Student student, Course course, Float score) {
return scoreService.addScore(score); return scoreService.addScore(student, course, score);
} }
@RequestMapping("delete") @RequestMapping("/delete")
public Result deleteScore(Score score) { public Result deleteScore(Score score) {
return scoreService.deleteScore(score); return scoreService.deleteScore(score);
} }
@RequestMapping("/getByStu")
public Result getScoreByStu(String studentCode) {
Student student = new Student();
student.setCode(studentCode);
return scoreService.getStudentScore(student);
}
} }

View File

@ -1,10 +0,0 @@
package test05.pojo;
public class CourseFront {
private int id;
private String name;
private int type;
private float credit;
private int grade;
private String detail;
}

View File

@ -1,11 +1,14 @@
package test05.service; package test05.service;
import test05.pojo.Course;
import test05.pojo.Result; import test05.pojo.Result;
import test05.pojo.Score; import test05.pojo.Score;
import test05.pojo.Student;
public interface ScoreService { public interface ScoreService {
Result addScore(Score score); Result addScore(Student student, Course course, Float score);
Result getScore(Score score); Result getScore(Student student, Course course);
Result deleteScore(Score score); Result deleteScore(Score score);
Result updateScore(Score score); Result updateScore(Score score);
Result getStudentScore(Student student);
} }

View File

@ -2,9 +2,13 @@ package test05.service.impl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import test05.mapper.CourseMapper;
import test05.mapper.ScoreMapper; import test05.mapper.ScoreMapper;
import test05.mapper.StudentMapper;
import test05.pojo.Course;
import test05.pojo.Result; import test05.pojo.Result;
import test05.pojo.Score; import test05.pojo.Score;
import test05.pojo.Student;
import test05.service.ScoreService; import test05.service.ScoreService;
import java.util.List; import java.util.List;
@ -12,24 +16,47 @@ import java.util.List;
@Service @Service
public class ScoreServiceImpl implements ScoreService { public class ScoreServiceImpl implements ScoreService {
ScoreMapper scoreMapper; ScoreMapper scoreMapper;
StudentMapper studentMapper;
CourseMapper courseMapper;
@Autowired @Autowired
public ScoreServiceImpl(ScoreMapper scoreMapper) { public ScoreServiceImpl(ScoreMapper scoreMapper, StudentMapper studentMapper, CourseMapper courseMapper) {
this.scoreMapper = scoreMapper; this.scoreMapper = scoreMapper;
this.studentMapper = studentMapper;
this.courseMapper = courseMapper;
} }
@Override @Override
public Result addScore(Score score) { public Result addScore(Student student, Course course, Float score) {
if(score.getScore()==-1||score.getStudentId()==-1||score.getCourseId()==-1){ if (student == null || student.getId()==-1){
return Result.error("incorrect score"); student = studentMapper.selectStudent(student, 1,10).getFirst();
} }
return Result.success(scoreMapper.insertScore(score)); if (course == null || course.getId()==-1){
course = courseMapper.selectCourse(course, 1,10).getFirst();
}
Score toCreate = new Score();
toCreate.setScore(score);
toCreate.setStudentId(student.getId());
toCreate.setCourseId(course.getId());
return Result.success(scoreMapper.insertScore(toCreate));
} }
@Override @Override
public Result getScore(Score score) { public Result getScore(Student student, Course course) {
if(score.getStudentId()==-1||score.getCourseId()==-1){ if (student == null || student.getId()==-1){
return Result.error("incorrect score"); student = studentMapper.selectStudent(student, 1,10).getFirst();
if (student == null){
student = new Student();
}
} }
if (course == null || course.getId()==-1){
course = courseMapper.selectCourse(course, 1,10).getFirst();
if (course == null){
course = new Course();
}
}
Score score = new Score();
score.setStudentId(student.getId());
score.setCourseId(course.getId());
List<Score> result = scoreMapper.selectScore(score); List<Score> result = scoreMapper.selectScore(score);
return Result.success(result, scoreMapper.selectScoreCount(score)); return Result.success(result, scoreMapper.selectScoreCount(score));
} }
@ -43,4 +70,26 @@ public class ScoreServiceImpl implements ScoreService {
public Result updateScore(Score score) { public Result updateScore(Score score) {
return Result.success(scoreMapper.updateScore(score)>0); return Result.success(scoreMapper.updateScore(score)>0);
} }
@Override
public Result getStudentScore(Student student) {
if (student == null||student.getCode().isEmpty()){
return Result.error("didn't find student");
}
student = studentMapper.selectStudent(student, 1,10).getFirst();
if (student == null){
return Result.error("didn't find student");
}
Score score = new Score();
score.setStudentId(student.getId());
List<Score> result = scoreMapper.selectScore(score);
int scoreCount = scoreMapper.selectScoreCount(score);
int scoreSum = 0;
for (Score s : result){
scoreSum += s.getScore();
}
Result rst = Result.success(scoreSum, scoreCount);
rst.setMsg(student.getName());
return rst;
}
} }

View File

@ -1,14 +1,14 @@
spring.application.name=test05 spring.application.name=test05
#\u4F7F\u7528\u672C\u5730\u6D4B\u8BD5\u6570\u636E\u5E93 #\u4F7F\u7528\u672C\u5730\u6D4B\u8BD5\u6570\u636E\u5E93
spring.datasource.driver-class-name=org.sqlite.JDBC #spring.datasource.driver-class-name=org.sqlite.JDBC
#spring.datasource.url=jdbc:sqlite:F:\\Work_Area\\desk\\database\\\u5B66\u4E60\\java\u6D4B\u8BD5\u6570\u636E\u5E93\\db_student.db spring.datasource.url=jdbc:mysql://www.awin-x.top:63306/db_student
spring.datasource.url=jdbc:sqlite::resource:db/db_student.db #spring.datasource.url=jdbc:sqlite::resource:db/db_student.db
##\u4F7F\u7528mysql\u6570\u636E\u5E93 ##\u4F7F\u7528mysql\u6570\u636E\u5E93
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.url=jdbc:mysql://localhost:3306/db_student.db #spring.datasource.url=jdbc:mysql://localhost:3306/db_student.db
#spring.datasource.username=root spring.datasource.username=admin
#spring.datasource.password=123456 spring.datasource.password=3131313xY
spring.datasource.druid.validation-query=SELECT 1 spring.datasource.druid.validation-query=SELECT 1

View File

@ -1 +1 @@
<!doctype html><html lang="zh-cn"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>student-information-sys</title><script defer="defer" src="/js/chunk-vendors.418e428c.js"></script><script defer="defer" src="/js/app.f724117d.js"></script><link href="/css/chunk-vendors.10dd4e95.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but student-information-sys doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body><link rel="stylesheet" href="css/main.css"></html> <!doctype html><html lang="zh-cn"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>student-information-sys</title><script defer="defer" src="/js/chunk-vendors.418e428c.js"></script><script defer="defer" src="/js/app.2666942b.js"></script><link href="/css/chunk-vendors.10dd4e95.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but student-information-sys doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body><link rel="stylesheet" href="css/main.css"></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
"use strict";(self["webpackChunkstudent_information_sys"]=self["webpackChunkstudent_information_sys"]||[]).push([[158],{158:function(e,t,s){s.r(t),s.d(t,{default:function(){return d}});var a=function(){var e=this,t=e._self._c;return t("div",[t("el-tabs",{on:{"tab-click":e.changeTab},model:{value:e.activeName,callback:function(t){e.activeName=t},expression:"activeName"}},[t("el-tab-pane",{attrs:{label:"学生成绩",name:"stu"}},[t("el-row",{attrs:{gutter:30}},[t("el-col",{attrs:{span:8}},[t("el-input",{attrs:{placeholder:"学号"},model:{value:e.studentCode,callback:function(t){e.studentCode=t},expression:"studentCode"}})],1),t("el-col",{attrs:{span:3}},[t("el-button",{attrs:{type:"primary"},on:{click:e.searchByStu}},[e._v("查询")])],1)],1),t("br"),t("br"),t("el-descriptions",{attrs:{title:"查询结果:"}},[t("el-descriptions-item",{attrs:{label:"学生姓名"}},[e._v(e._s(e.studentScore.name))]),t("el-descriptions-item",{attrs:{label:"学号"}},[e._v(e._s(e.studentScore.code))]),t("el-descriptions-item",{attrs:{label:"学分"}},[e._v(e._s(e.studentScore.score))]),t("el-descriptions-item",{attrs:{label:"课程数"}},[e._v(e._s(e.studentScore.count))])],1)],1),t("el-tab-pane",{attrs:{label:"课程成绩",name:"cou"}},[t("el-form-item",{attrs:{label:"课程名称"}},[t("el-input",{attrs:{placeholder:"课程名称"},model:{value:e.studentCode,callback:function(t){e.studentCode=t},expression:"studentCode"}})],1),t("el-button",{attrs:{type:"primary"},on:{click:e.searchByCou}},[e._v("查询")]),t("el-table",{attrs:{data:e.scoreList}})],1)],1)],1)},o=[],n=s(1728),r=s.n(n),l={data(){return{activeName:"stu",studentCode:"",studentScore:{name:"",code:"",score:"",count:0},scoreList:{}}},methods:{handleClick(e,t){console.log(e,t)},searchByStu(){r().ajax({url:this.$apiUrl+"/scoreAction/getByStu",method:"GET",data:{studentCode:this.studentCode},success:e=>{e.success?(this.studentScore.code=this.studentCode,this.studentScore.name=e.msg,this.studentScore.score=e.data,this.studentScore.count=e.count):this.$message({type:"error",message:"查询失败",showClose:!0})},error:e=>{this.$message({type:"error",message:"请求数据失败code="+e.status,showClose:!0})}})},searchByCou(){}},mounted(){}},c=l,u=s(8126),i=(0,u.A)(c,a,o,!1,null,null,null),d=i.exports}}]);
//# sourceMappingURL=158.b09d1e82.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long