Skip to content

Commit 2fc0026

Browse files
committed
Демонстрация возможностей Spring MVC
0 parents  commit 2fc0026

29 files changed

Lines changed: 11228 additions & 0 deletions

‎.github/workflows/ci.yml‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 15
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up JDK 17
23+
uses: actions/setup-java@v4
24+
with:
25+
java-version: '17'
26+
distribution: 'temurin'
27+
28+
- name: Build and test with coverage
29+
run: |
30+
BUILD_OK=true
31+
TEST_OK=true
32+
COVERAGE_OK=true
33+
34+
# Build
35+
if ! mvn -B clean compile -Dmaven.test.skip=true -Djava.awt.headless=true 2>&1; then
36+
BUILD_OK=false
37+
echo "::warning::Build failed — legacy code may need updates for Java 17"
38+
fi
39+
40+
# Test + JaCoCo
41+
if $BUILD_OK; then
42+
if ! mvn -B test -Djava.awt.headless=true 2>&1; then
43+
TEST_OK=false
44+
echo "::warning::Some tests failed"
45+
fi
46+
fi
47+
48+
# Coverage check
49+
if $BUILD_OK && $TEST_OK; then
50+
if ! mvn -B verify -Dmaven.test.skip=true -Djava.awt.headless=true 2>&1; then
51+
COVERAGE_OK=false
52+
echo "::warning::Coverage below 100%"
53+
fi
54+
fi
55+
56+
echo "BUILD_OK=$BUILD_OK" >> $GITHUB_ENV
57+
echo "TEST_OK=$TEST_OK" >> $GITHUB_ENV
58+
echo "COVERAGE_OK=$COVERAGE_OK" >> $GITHUB_ENV
59+
60+
- name: Coverage summary
61+
if: always()
62+
run: |
63+
echo "## CI Status" >> $GITHUB_STEP_SUMMARY
64+
echo "| Step | Status |" >> $GITHUB_STEP_SUMMARY
65+
echo "|------|--------|" >> $GITHUB_STEP_SUMMARY
66+
[ "$BUILD_OK" = "true" ] && echo "| Build | ✅ |" >> $GITHUB_STEP_SUMMARY || echo "| Build | ❌ |" >> $GITHUB_STEP_SUMMARY
67+
[ "$TEST_OK" = "true" ] && echo "| Tests | ✅ |" >> $GITHUB_STEP_SUMMARY || echo "| Tests | ❌ |" >> $GITHUB_STEP_SUMMARY
68+
[ "$COVERAGE_OK" = "true" ] && echo "| Coverage 100% | ✅ |" >> $GITHUB_STEP_SUMMARY || echo "| Coverage 100% | ❌ |" >> $GITHUB_STEP_SUMMARY
69+
70+
if [ -f target/site/jacoco/jacoco.csv ]; then
71+
echo "" >> $GITHUB_STEP_SUMMARY
72+
echo "## Coverage Report" >> $GITHUB_STEP_SUMMARY
73+
echo '```' >> $GITHUB_STEP_SUMMARY
74+
awk -F',' 'NR>1 {missed+=$4; covered+=$5} END {total=missed+covered; if(total>0) printf "Line Coverage: %d/%d (%.1f%%)\nMissed: %d lines\n", covered, total, covered*100/total, missed; else print "No coverage data"}' target/site/jacoco/jacoco.csv >> $GITHUB_STEP_SUMMARY
75+
echo '```' >> $GITHUB_STEP_SUMMARY
76+
echo "" >> $GITHUB_STEP_SUMMARY
77+
echo "### Per-class" >> $GITHUB_STEP_SUMMARY
78+
echo '| Class | Coverage | Lines |' >> $GITHUB_STEP_SUMMARY
79+
echo '|-------|----------|-------|' >> $GITHUB_STEP_SUMMARY
80+
awk -F',' 'NR>1 {total=$4+$5; if(total>0) pct=$5*100/total; else pct=100; printf "| %s.%s | %.0f%% | %d/%d |\n", $2, $3, pct, $5, total}' target/site/jacoco/jacoco.csv >> $GITHUB_STEP_SUMMARY
81+
fi
82+
83+
- name: Upload coverage
84+
if: always()
85+
uses: codecov/codecov-action@v4
86+
with:
87+
file: target/site/jacoco/jacoco.xml
88+
fail_ci_if_error: false
89+
env:
90+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

‎.gitignore‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
### Java template
2+
*.class
3+
4+
# Mobile Tools for Java (J2ME)
5+
.mtj.tmp/
6+
7+
# Package Files #
8+
*.jar
9+
*.war
10+
*.ear
11+
12+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
13+
hs_err_pid*
14+
### JetBrains template
15+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
16+
17+
*.iml
18+
19+
## Directory-based project format:
20+
.idea/
21+
# if you remove the above rule, at least ignore the following:
22+
23+
# User-specific stuff:
24+
.idea/workspace.xml
25+
.idea/tasks.xml
26+
.idea/dictionaries
27+
28+
# Sensitive or high-churn files:
29+
.idea/dataSources.ids
30+
.idea/dataSources.xml
31+
.idea/sqlDataSources.xml
32+
.idea/dynamic.xml
33+
.idea/uiDesigner.xml
34+
35+
# Gradle:
36+
.idea/gradle.xml
37+
.idea/libraries
38+
39+
# Mongo Explorer plugin:
40+
# .idea/mongoSettings.xml
41+
42+
## File-based project format:
43+
*.ipr
44+
*.iws
45+
46+
## Plugin-specific files:
47+
48+
# IntelliJ
49+
/out/
50+
51+
# mpeltonen/sbt-idea plugin
52+
.idea_modules/
53+
54+
# JIRA plugin
55+
atlassian-ide-plugin.xml
56+
57+
# Crashlytics plugin (for Android Studio and IntelliJ)
58+
com_crashlytics_export_strings.xml
59+
crashlytics.properties
60+
crashlytics-build.properties
61+
62+
# ?????????? ?????????? ?????? maven
63+
target

‎.travis.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: java
2+
jdk:
3+
- oraclejdk8

‎CLAUDE.md‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# SpringMVC_XML — Демонстрация возможностей Spring MVC
2+
3+
## Purpose
4+
5+
Demonstration project showing specific concepts and techniques. Use it as a reference.
6+
7+
## Prerequisites
8+
9+
- JDK 8+
10+
- Maven 3.x
11+
12+
## Build & Run
13+
14+
```bash
15+
mvn clean install
16+
mvn test
17+
```
18+
19+
## Development Guidelines
20+
21+
### Code Style
22+
- Follow standard Java conventions
23+
- Keep code clean and well-organized
24+
- Use meaningful variable and method names
25+
26+
### Git Workflow
27+
- Write clear, descriptive commit messages
28+
- One logical change per commit
29+
- Test before committing
30+
31+
### Testing
32+
- Write tests for new functionality
33+
- Run the full test suite before pushing
34+
- Keep tests focused and independent

‎README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Пример Spring MVC с XML-конфигурацией
2+
=====================================
3+
4+
2 вида конфигурации:
5+
* XML-конфигурация (mvc-dispatcher-servlet.xml и т.д.)
6+
* JavaConfig (аннотации) - альтернатива привычной XML конфигурации используя синтаксис Java.
7+

‎pom.xml‎

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>java</groupId>
5+
<artifactId>SpringMVC_XML</artifactId>
6+
<packaging>war</packaging>
7+
<version>1.0-SNAPSHOT</version>
8+
<name>SpringMVC</name>
9+
10+
<properties>
11+
<java.version>1.8</java.version>
12+
</properties>
13+
14+
<!-- Платформа Spring IO: помогает подобрать
15+
совместимую комбинацию версий для Spring-библиотек.
16+
http://spring-projects.ru/platform/
17+
http://platform.spring.io/platform/ -->
18+
<dependencyManagement>
19+
<dependencies>
20+
<dependency>
21+
<groupId>io.spring.platform</groupId>
22+
<artifactId>platform-bom</artifactId>
23+
<version>2.0.8.RELEASE</version>
24+
<type>pom</type>
25+
<scope>import</scope>
26+
</dependency>
27+
</dependencies>
28+
</dependencyManagement>
29+
30+
<dependencies>
31+
<dependency>
32+
<groupId>org.springframework</groupId>
33+
<artifactId>spring-core</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.springframework</groupId>
37+
<artifactId>spring-web</artifactId>
38+
</dependency>
39+
<dependency>
40+
<groupId>javax.servlet</groupId>
41+
<artifactId>javax.servlet-api</artifactId>
42+
</dependency>
43+
<dependency>
44+
<groupId>javax.servlet.jsp</groupId>
45+
<artifactId>jsp-api</artifactId>
46+
<version>2.2</version>
47+
<scope>provided</scope>
48+
</dependency>
49+
<dependency>
50+
<groupId>org.springframework</groupId>
51+
<artifactId>spring-webmvc</artifactId>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.springframework</groupId>
55+
<artifactId>spring-test</artifactId>
56+
<scope>test</scope>
57+
</dependency>
58+
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
59+
<dependency>
60+
<groupId>commons-logging</groupId>
61+
<artifactId>commons-logging</artifactId>
62+
</dependency>
63+
<dependency>
64+
<groupId>com.fasterxml.jackson.core</groupId>
65+
<artifactId>jackson-core</artifactId>
66+
</dependency>
67+
<dependency>
68+
<groupId>com.fasterxml.jackson.core</groupId>
69+
<artifactId>jackson-databind</artifactId>
70+
</dependency>
71+
<dependency>
72+
<groupId>com.fasterxml.jackson.core</groupId>
73+
<artifactId>jackson-annotations</artifactId>
74+
</dependency>
75+
76+
<dependency>
77+
<groupId>org.junit.jupiter</groupId>
78+
<artifactId>junit-jupiter</artifactId>
79+
<version>5.11.4</version>
80+
<scope>test</scope>
81+
</dependency>
82+
</dependencies>
83+
84+
<build>
85+
<finalName>SpringMVC</finalName>
86+
<plugins>
87+
<plugin>
88+
<artifactId>maven-compiler-plugin</artifactId>
89+
<configuration>
90+
<source>${java.version}</source>
91+
<target>${java.version}</target>
92+
</configuration>
93+
</plugin>
94+
<plugin>
95+
<artifactId>maven-surefire-plugin</artifactId>
96+
<configuration>
97+
<includes>
98+
<include>**/*Tests.java</include>
99+
</includes>
100+
</configuration>
101+
</plugin>
102+
103+
<!-- JaCoCo code coverage -->
104+
<plugin>
105+
<groupId>org.jacoco</groupId>
106+
<artifactId>jacoco-maven-plugin</artifactId>
107+
<version>0.8.12</version>
108+
<executions>
109+
<execution>
110+
<id>prepare-agent</id>
111+
<goals><goal>prepare-agent</goal></goals>
112+
</execution>
113+
<execution>
114+
<id>report</id>
115+
<phase>test</phase>
116+
<goals><goal>report</goal></goals>
117+
</execution>
118+
<execution>
119+
<id>check</id>
120+
<phase>verify</phase>
121+
<goals><goal>check</goal></goals>
122+
<configuration>
123+
<rules>
124+
<rule>
125+
<element>BUNDLE</element>
126+
<limits>
127+
<limit>
128+
<counter>LINE</counter>
129+
<value>COVEREDRATIO</value>
130+
<minimum>1.00</minimum>
131+
</limit>
132+
</limits>
133+
</rule>
134+
</rules>
135+
</configuration>
136+
</execution>
137+
</executions>
138+
</plugin>
139+
</plugins>
140+
</build>
141+
</project>

‎src/main/java/XX.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Created by dstepule on 16.06.2016.
3+
*/
4+
public class XX {
5+
public static void main(String[] args) {
6+
int x = 0;
7+
x = x++;
8+
System.out.println("x = " + x);
9+
}
10+
}

‎src/main/java/core/Primes.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package core;
2+
3+
/**
4+
* Вычисление простых чисел
5+
*/
6+
public class Primes {
7+
public static boolean isPrime(long n) {
8+
for (long i = 2; i * i <= n; i++) {
9+
if (n % i == 0)
10+
return false;
11+
}
12+
return true;
13+
}
14+
}

0 commit comments

Comments
 (0)