This is a Java 21 + Scala 3 web application (WAR) for Linux.org.ru. It uses Maven for build, Spring Framework, and includes both unit and integration tests.
mvn package -DskipTests # Build WAR without running tests
mvn compile # Compile main sources only
mvn test-compile # Compile main and test sourcesRun all unit tests only (no integration tests):
mvn testRun a single test class:
mvn test -Dtest=StringUtilTest
mvn test -Dtest=ru.org.linux.util.StringUtilTestRun a single test method:
mvn test -Dtest=StringUtilTest#processTitleRun integration tests:
mvn integration-test Run a single integration test:
mvn integration-test -Dit.test=TopicControllerIntegrationTestRun all tests (unit + integration):
mvn verifyRun in background shell:
mvn -DskipTests package jetty:run > server.log 2>&1 &Important: The development web server must be restarted after any changes to the code.
Stop server with:
mvn jetty:stopServer starts at http://127.0.0.1:8080/
mvn clean # Clean target directory
mvn dependency:tree # Show dependency tree- All source files must include the Apache License header (see existing files)
- Maximum line length: 120 characters (enforced by Scalafmt)
- Package structure:
ru.org.linux.*
- Use Spring annotations:
@Repository,@Service,@Controller, etc. - Use
@Nullableand@Nonnullannotations fromjavax.annotation - Use Java 17+ features (records, pattern matching) where appropriate
- Use
Optionalinstead of null returns - Use constructor injection over field injection
- Import order: java., javax., org., com., ru.*
- Follow
.scalafmt.confconfiguration (version 3.10.7, Scala 3 dialect) - Use strict logging:
com.typesafe.scalalogging.StrictLogging - Use Akka/Pekko for async operations
- Java classes:
CamelCase(e.g.,UserDao,TopicController) - Scala classes/objects:
CamelCase(e.g.,CommentCreateService) - Methods/fields:
camelCase - Java constants:
UPPER_SNAKE_CASE - Scala constants:
UpperCamelCase - Test classes:
*Test,*IntegrationTest,*WebTest.scala
- Use custom exceptions (e.g.,
MessageNotFoundException,UserNotFoundException) - Return
Optional<T>for potentially missing values - Use Spring's
@ExceptionHandlerfor controller-level error handling - Log errors with appropriate levels (error for exceptions, info/debug for flow)
- Use JUnit 4/5 for Java unit tests
- Use MUnit for Scala tests
- Follow AAA pattern (Arrange/Act/Assert or Given/When/Then)
- Place test classes in same package under
src/test/javaorsrc/test/scala - Integration tests require database (use testcontainers if needed)
- Use Spring's
JdbcTemplateandNamedParameterJdbcTemplate - Use
@Transactionalfor database operations on Java and.transactional()on Scala - Repository pattern with
@Repositoryannotation
- Spring Framework 6.x
- Spring Security 6.x
- PostgreSQL JDBC driver
- OpenSearch 3 via opensearch-java.
- Pekko for async
src/
├── main/
│ ├── java/ru/org/linux/ # Java sources
│ └── scala/ru/org/linux/ # Scala sources
├── test/
│ ├── java/ru/org/linux/ # Java test sources
│ ├── scala/ru/org/linux/ # Scala test sources
│ └── resources/ # Test resources (spring configs, etc.)
- IntelliJ IDEA (has good Scala/Java support)
- For VS Code: Use Java extension with null analysis mode set to "automatic"