diff --git a/spring-boot-mvc/README.md b/spring-boot-mvc/README.md index a22a6df667..b46dbe3bae 100644 --- a/spring-boot-mvc/README.md +++ b/spring-boot-mvc/README.md @@ -2,3 +2,9 @@ - [Guide to the Favicon in Spring Boot](http://www.baeldung.com/spring-boot-favicon) - [Custom Validation MessageSource in Spring Boot](https://www.baeldung.com/spring-custom-validation-message-source) +- [Spring Boot Annotations](http://www.baeldung.com/spring-boot-annotations) +- [Spring Scheduling Annotations](http://www.baeldung.com/spring-scheduling-annotations) +- [Spring Web Annotations](http://www.baeldung.com/spring-mvc-annotations) +- [Spring Core Annotations](http://www.baeldung.com/spring-core-annotations) +- [Display RSS Feed with Spring MVC](http://www.baeldung.com/spring-mvc-rss-feed) + diff --git a/spring-boot-mvc/pom.xml b/spring-boot-mvc/pom.xml index d0fce26bb5..e456155f36 100644 --- a/spring-boot-mvc/pom.xml +++ b/spring-boot-mvc/pom.xml @@ -32,6 +32,13 @@ org.springframework.boot spring-boot-starter-validation + + + + com.rometools + rome + ${rome.version} + @@ -47,6 +54,8 @@ UTF-8 UTF-8 1.8 + + 1.10.0 diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/Bike.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/Bike.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/Bike.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/Bike.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/Biker.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/Biker.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/Biker.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/Biker.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/Car.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/Car.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/Car.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/Car.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/CarMechanic.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/CarMechanic.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/CarMechanic.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/CarMechanic.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/CarUtility.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/CarUtility.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/CarUtility.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/CarUtility.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/CustomException.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/CustomException.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/CustomException.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/CustomException.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/CustomResponseController.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/CustomResponseController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/CustomResponseController.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/CustomResponseController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/CustomResponseWithBuilderController.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/CustomResponseWithBuilderController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/CustomResponseWithBuilderController.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/CustomResponseWithBuilderController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/Driver.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/Driver.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/Driver.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/Driver.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/Engine.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/Engine.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/Engine.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/Engine.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/Vehicle.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/Vehicle.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/Vehicle.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/Vehicle.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/VehicleController.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/VehicleController.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/VehicleFactoryApplication.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryApplication.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/VehicleFactoryApplication.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryApplication.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/VehicleFactoryConfig.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryConfig.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/VehicleFactoryConfig.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleFactoryConfig.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/VehicleRepository.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRepository.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/VehicleRepository.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRepository.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/VehicleRestController.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRestController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/VehicleRestController.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleRestController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/annotations/VehicleService.java b/spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleService.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/annotations/VehicleService.java rename to spring-boot-mvc/src/main/java/com/baeldung/annotations/VehicleService.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/rss/RssFeedApplication.java b/spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedApplication.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/rss/RssFeedApplication.java rename to spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedApplication.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/rss/RssFeedController.java b/spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/rss/RssFeedController.java rename to spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/rss/RssFeedView.java b/spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedView.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/rss/RssFeedView.java rename to spring-boot-mvc/src/main/java/com/baeldung/rss/RssFeedView.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/rss/RssFeedUnitTest.java b/spring-boot-mvc/src/test/java/com/baeldung/rss/RssFeedUnitTest.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/rss/RssFeedUnitTest.java rename to spring-boot-mvc/src/test/java/com/baeldung/rss/RssFeedUnitTest.java diff --git a/spring-mvc-java/.pmd b/spring-mvc-java/.pmd new file mode 100644 index 0000000000..b4153e4810 --- /dev/null +++ b/spring-mvc-java/.pmd @@ -0,0 +1,1572 @@ + + + false + .ruleset + + + + + AbstractClassWithoutAbstractMethod + Best Practices + + + AccessorClassGeneration + Best Practices + + + AccessorMethodGeneration + Best Practices + + + ApexUnitTestClassShouldHaveAsserts + Best Practices + + + ApexUnitTestShouldNotUseSeeAllDataTrue + Best Practices + + + ArrayIsStoredDirectly + Best Practices + + + AvoidGlobalModifier + Best Practices + + + AvoidLogicInTrigger + Best Practices + + + AvoidPrintStackTrace + Best Practices + + + AvoidReassigningParameters + Best Practices + + + AvoidReassigningParameters + Best Practices + + + AvoidStringBufferField + Best Practices + + + AvoidUsingHardCodedIP + Best Practices + + + AvoidWithStatement + Best Practices + + + CheckResultSet + Best Practices + + + ConsistentReturn + Best Practices + + + ConstantsInInterface + Best Practices + + + DefaultLabelNotLastInSwitchStmt + Best Practices + + + DontNestJsfInJstlIteration + Best Practices + + + ForLoopCanBeForeach + Best Practices + + + GlobalVariable + Best Practices + + + GuardLogStatement + Best Practices + + + JUnit4SuitesShouldUseSuiteAnnotation + Best Practices + + + JUnit4TestShouldUseAfterAnnotation + Best Practices + + + JUnit4TestShouldUseBeforeAnnotation + Best Practices + + + JUnit4TestShouldUseTestAnnotation + Best Practices + + + JUnitAssertionsShouldIncludeMessage + Best Practices + + + JUnitTestContainsTooManyAsserts + Best Practices + + + JUnitTestsShouldIncludeAssert + Best Practices + + + JUnitUseExpected + Best Practices + + + LooseCoupling + Best Practices + + + MethodReturnsInternalArray + Best Practices + + + MissingOverride + Best Practices + + + NoClassAttribute + Best Practices + + + NoHtmlComments + Best Practices + + + NoJspForward + Best Practices + + + OneDeclarationPerLine + Best Practices + + + PositionLiteralsFirstInCaseInsensitiveComparisons + Best Practices + + + PositionLiteralsFirstInComparisons + Best Practices + + + PreserveStackTrace + Best Practices + + + ReplaceEnumerationWithIterator + Best Practices + + + ReplaceHashtableWithMap + Best Practices + + + ReplaceVectorWithList + Best Practices + + + ScopeForInVariable + Best Practices + + + SwitchStmtsShouldHaveDefault + Best Practices + + + SystemPrintln + Best Practices + + + TomKytesDespair + Best Practices + + + UnusedFormalParameter + Best Practices + + + UnusedImports + Best Practices + + + UnusedLocalVariable + Best Practices + + + UnusedMacroParameter + Best Practices + + + UnusedPrivateField + Best Practices + + + UnusedPrivateMethod + Best Practices + + + UseAssertEqualsInsteadOfAssertTrue + Best Practices + + + UseAssertNullInsteadOfAssertTrue + Best Practices + + + UseAssertSameInsteadOfAssertTrue + Best Practices + + + UseAssertTrueInsteadOfAssertEquals + Best Practices + + + UseBaseWithParseInt + Best Practices + + + UseCollectionIsEmpty + Best Practices + + + UseVarargs + Best Practices + + + AbstractNaming + Code Style + + + AssignmentInOperand + Code Style + + + AtLeastOneConstructor + Code Style + + + AvoidDollarSigns + Code Style + + + AvoidFinalLocalVariable + Code Style + + + AvoidPrefixingMethodParameters + Code Style + + + AvoidProtectedFieldInFinalClass + Code Style + + + AvoidProtectedMethodInFinalClassNotExtending + Code Style + + + AvoidUsingNativeCode + Code Style + + + BooleanGetMethodName + Code Style + + + CallSuperInConstructor + Code Style + + + ClassNamingConventions + Code Style + + + ClassNamingConventions + Code Style + + + CommentDefaultAccessModifier + Code Style + + + ConfusingTernary + Code Style + + + ControlStatementBraces + Code Style + + + DefaultPackage + Code Style + + + DontImportJavaLang + Code Style + + + DuplicateImports + Code Style + + + DuplicateJspImports + Code Style + + + EmptyMethodInAbstractClassShouldBeAbstract + Code Style + + + ExtendsObject + Code Style + + + FieldDeclarationsShouldBeAtStartOfClass + Code Style + + + ForLoopShouldBeWhileLoop + Code Style + + + ForLoopsMustUseBraces + Code Style + + + ForLoopsMustUseBraces + Code Style + + + ForLoopsMustUseBraces + Code Style + + + GenericsNaming + Code Style + + + IfElseStmtsMustUseBraces + Code Style + + + IfElseStmtsMustUseBraces + Code Style + + + IfElseStmtsMustUseBraces + Code Style + + + IfStmtsMustUseBraces + Code Style + + + IfStmtsMustUseBraces + Code Style + + + IfStmtsMustUseBraces + Code Style + + + LocalHomeNamingConvention + Code Style + + + LocalInterfaceSessionNamingConvention + Code Style + + + LocalVariableCouldBeFinal + Code Style + + + LongVariable + Code Style + + + MDBAndSessionBeanNamingConvention + Code Style + + + MethodArgumentCouldBeFinal + Code Style + + + MethodNamingConventions + Code Style + + + MethodNamingConventions + Code Style + + + MIsLeadingVariableName + Code Style + + + MisplacedPragma + Code Style + + + NoElseReturn + Code Style + + + NoPackage + Code Style + + + OnlyOneReturn + Code Style + + + PackageCase + Code Style + + + PrematureDeclaration + Code Style + + + RemoteInterfaceNamingConvention + Code Style + + + RemoteSessionInterfaceNamingConvention + Code Style + + + ShortClassName + Code Style + + + ShortMethodName + Code Style + + + ShortVariable + Code Style + + + SuspiciousConstantFieldName + Code Style + + + TooManyStaticImports + Code Style + + + UnnecessaryAnnotationValueElement + Code Style + + + UnnecessaryBlock + Code Style + + + UnnecessaryConstructor + Code Style + + + UnnecessaryFullyQualifiedName + Code Style + + + UnnecessaryLocalBeforeReturn + Code Style + + + UnnecessaryModifier + Code Style + + + UnnecessaryParentheses + Code Style + + + UnnecessaryReturn + Code Style + + + UnreachableCode + Code Style + + + UseConcatOnce + Code Style + + + UselessParentheses + Code Style + + + UselessQualifiedThis + Code Style + + + VariableNamingConventions + Code Style + + + VariableNamingConventions + Code Style + + + WhileLoopsMustUseBraces + Code Style + + + WhileLoopsMustUseBraces + Code Style + + + WhileLoopsMustUseBraces + Code Style + + + AbstractClassWithoutAnyMethod + Design + + + AvoidCatchingGenericException + Design + + + AvoidDeeplyNestedIfStmts + Design + + + AvoidDeeplyNestedIfStmts + Design + + + AvoidDeeplyNestedIfStmts + Design + + + AvoidRethrowingException + Design + + + AvoidThrowingNewInstanceOfSameException + Design + + + AvoidThrowingNullPointerException + Design + + + AvoidThrowingRawExceptionTypes + Design + + + ClassWithOnlyPrivateConstructorsShouldBeFinal + Design + + + CollapsibleIfStatements + Design + + + CollapsibleIfStatements + Design + + + CouplingBetweenObjects + Design + + + CyclomaticComplexity + Design + + + CyclomaticComplexity + Design + + + CyclomaticComplexity + Design + + + DataClass + Design + + + DoNotExtendJavaLangError + Design + + + ExceptionAsFlowControl + Design + + + ExcessiveClassLength + Design + + + ExcessiveClassLength + Design + + + ExcessiveImports + Design + + + ExcessiveMethodLength + Design + + + ExcessiveMethodLength + Design + + + ExcessiveObjectLength + Design + + + ExcessivePackageBodyLength + Design + + + ExcessivePackageSpecificationLength + Design + + + ExcessiveParameterList + Design + + + ExcessiveParameterList + Design + + + ExcessiveParameterList + Design + + + ExcessivePublicCount + Design + + + ExcessivePublicCount + Design + + + ExcessiveTemplateLength + Design + + + ExcessiveTypeLength + Design + + + FinalFieldCouldBeStatic + Design + + + GodClass + Design + + + ImmutableField + Design + + + LawOfDemeter + Design + + + LogicInversion + Design + + + LoosePackageCoupling + Design + + + ModifiedCyclomaticComplexity + Design + + + NcssConstructorCount + Design + + + NcssConstructorCount + Design + + + NcssCount + Design + + + NcssMethodCount + Design + + + NcssMethodCount + Design + + + NcssMethodCount + Design + + + NcssObjectCount + Design + + + NcssTypeCount + Design + + + NcssTypeCount + Design + + + NoInlineJavaScript + Design + + + NoInlineScript + Design + + + NoInlineStyleInformation + Design + + + NoInlineStyles + Design + + + NoLongScripts + Design + + + NoScriptlets + Design + + + NPathComplexity + Design + + + NPathComplexity + Design + + + SignatureDeclareThrowsException + Design + + + SimplifiedTernary + Design + + + SimplifyBooleanAssertion + Design + + + SimplifyBooleanExpressions + Design + + + SimplifyBooleanReturns + Design + + + SimplifyConditional + Design + + + SingularField + Design + + + StdCyclomaticComplexity + Design + + + StdCyclomaticComplexity + Design + + + SwitchDensity + Design + + + TooManyFields + Design + + + TooManyFields + Design + + + TooManyFields + Design + + + TooManyMethods + Design + + + TooManyMethods + Design + + + UselessOverridingMethod + Design + + + UseObjectForClearerAPI + Design + + + UseUtilityClass + Design + + + CommentContent + Documentation + + + CommentRequired + Documentation + + + CommentSize + Documentation + + + UncommentedEmptyConstructor + Documentation + + + UncommentedEmptyMethodBody + Documentation + + + AssignmentInOperand + Error Prone + + + AssignmentToNonFinalStatic + Error Prone + + + AvoidAccessibilityAlteration + Error Prone + + + AvoidAssertAsIdentifier + Error Prone + + + AvoidBranchingStatementAsLastInLoop + Error Prone + + + AvoidCallingFinalize + Error Prone + + + AvoidCatchingNPE + Error Prone + + + AvoidCatchingThrowable + Error Prone + + + AvoidDecimalLiteralsInBigDecimalConstructor + Error Prone + + + AvoidDirectAccessTriggerMap + Error Prone + + + AvoidDuplicateLiterals + Error Prone + + + AvoidEnumAsIdentifier + Error Prone + + + AvoidFieldNameMatchingMethodName + Error Prone + + + AvoidFieldNameMatchingTypeName + Error Prone + + + AvoidHardcodingId + Error Prone + + + AvoidInstanceofChecksInCatchClause + Error Prone + + + AvoidLiteralsInIfCondition + Error Prone + + + AvoidLosingExceptionInformation + Error Prone + + + AvoidMultipleUnaryOperators + Error Prone + + + AvoidTrailingComma + Error Prone + + + AvoidUsingOctalValues + Error Prone + + + BadComparison + Error Prone + + + BeanMembersShouldSerialize + Error Prone + + + BrokenNullCheck + Error Prone + + + CallSuperFirst + Error Prone + + + CallSuperLast + Error Prone + + + CheckSkipResult + Error Prone + + + ClassCastExceptionWithToArray + Error Prone + + + CloneMethodMustBePublic + Error Prone + + + CloneMethodMustImplementCloneable + Error Prone + + + CloneMethodReturnTypeMustMatchClassName + Error Prone + + + CloneThrowsCloneNotSupportedException + Error Prone + + + CloseResource + Error Prone + + + CompareObjectsWithEquals + Error Prone + + + ConstructorCallsOverridableMethod + Error Prone + + + DataflowAnomalyAnalysis + Error Prone + + + DoNotCallGarbageCollectionExplicitly + Error Prone + + + DoNotCallSystemExit + Error Prone + + + DoNotExtendJavaLangThrowable + Error Prone + + + DoNotHardCodeSDCard + Error Prone + + + DoNotThrowExceptionInFinally + Error Prone + + + DontImportSun + Error Prone + + + DontUseFloatTypeForLoopIndices + Error Prone + + + EmptyCatchBlock + Error Prone + + + EmptyCatchBlock + Error Prone + + + EmptyFinalizer + Error Prone + + + EmptyFinallyBlock + Error Prone + + + EmptyForeachStmt + Error Prone + + + EmptyIfStmt + Error Prone + + + EmptyIfStmt + Error Prone + + + EmptyIfStmt + Error Prone + + + EmptyInitializer + Error Prone + + + EmptyStatementBlock + Error Prone + + + EmptyStatementBlock + Error Prone + + + EmptyStatementNotInLoop + Error Prone + + + EmptySwitchStatements + Error Prone + + + EmptySynchronizedBlock + Error Prone + + + EmptyTryBlock + Error Prone + + + EmptyTryOrFinallyBlock + Error Prone + + + EmptyWhileStmt + Error Prone + + + EmptyWhileStmt + Error Prone + + + EqualComparison + Error Prone + + + EqualsNull + Error Prone + + + FinalizeDoesNotCallSuperFinalize + Error Prone + + + FinalizeOnlyCallsSuperFinalize + Error Prone + + + FinalizeOverloaded + Error Prone + + + FinalizeShouldBeProtected + Error Prone + + + IdempotentOperations + Error Prone + + + ImportFromSamePackage + Error Prone + + + InnaccurateNumericLiteral + Error Prone + + + InstantiationToGetClass + Error Prone + + + InvalidDependencyTypes + Error Prone + + + InvalidSlf4jMessageFormat + Error Prone + + + JspEncoding + Error Prone + + + JumbledIncrementer + Error Prone + + + JUnitSpelling + Error Prone + + + JUnitStaticSuite + Error Prone + + + LoggerIsNotStaticFinal + Error Prone + + + MethodWithSameNameAsEnclosingClass + Error Prone + + + MethodWithSameNameAsEnclosingClass + Error Prone + + + MisplacedNullCheck + Error Prone + + + MissingBreakInSwitch + Error Prone + + + MissingSerialVersionUID + Error Prone + + + MissingStaticMethodInNonInstantiatableClass + Error Prone + + + MistypedCDATASection + Error Prone + + + MoreThanOneLogger + Error Prone + + + NonCaseLabelInSwitchStatement + Error Prone + + + NonStaticInitializer + Error Prone + + + NullAssignment + Error Prone + + + OverrideBothEqualsAndHashcode + Error Prone + + + ProjectVersionAsDependencyVersion + Error Prone + + + ProperCloneImplementation + Error Prone + + + ProperLogger + Error Prone + + + ReturnEmptyArrayRatherThanNull + Error Prone + + + ReturnFromFinallyBlock + Error Prone + + + SimpleDateFormatNeedsLocale + Error Prone + + + SingleMethodSingleton + Error Prone + + + SingletonClassReturningNewInstance + Error Prone + + + StaticEJBFieldShouldBeFinal + Error Prone + + + StringBufferInstantiationWithChar + Error Prone + + + SuspiciousEqualsMethodName + Error Prone + + + SuspiciousHashcodeMethodName + Error Prone + + + SuspiciousOctalEscape + Error Prone + + + TestClassWithoutTestCases + Error Prone + + + TO_DATEWithoutDateFormat + Error Prone + + + TO_DATE_TO_CHAR + Error Prone + + + TO_TIMESTAMPWithoutDateFormat + Error Prone + + + UnconditionalIfStatement + Error Prone + + + UnnecessaryBooleanAssertion + Error Prone + + + UnnecessaryCaseChange + Error Prone + + + UnnecessaryConversionTemporary + Error Prone + + + UnusedNullCheckInEquals + Error Prone + + + UseCorrectExceptionLogging + Error Prone + + + UseEqualsToCompareStrings + Error Prone + + + UselessOperationOnImmutable + Error Prone + + + UseLocaleWithCaseConversions + Error Prone + + + UseProperClassLoader + Error Prone + + + AvoidSynchronizedAtMethodLevel + Multithreading + + + AvoidThreadGroup + Multithreading + + + AvoidUsingVolatile + Multithreading + + + DoNotUseThreads + Multithreading + + + DontCallThreadRun + Multithreading + + + DoubleCheckedLocking + Multithreading + + + NonThreadSafeSingleton + Multithreading + + + UnsynchronizedStaticDateFormatter + Multithreading + + + UseConcurrentHashMap + Multithreading + + + UseNotifyAllInsteadOfNotify + Multithreading + + + AddEmptyString + Performance + + + AppendCharacterWithChar + Performance + + + AvoidArrayLoops + Performance + + + AvoidAxisNavigation + Performance + + + AvoidDmlStatementsInLoops + Performance + + + AvoidFileStream + Performance + + + AvoidInstantiatingObjectsInLoops + Performance + + + AvoidSoqlInLoops + Performance + + + AvoidSoslInLoops + Performance + + + AvoidUsingShortType + Performance + + + BigIntegerInstantiation + Performance + + + BooleanInstantiation + Performance + + + ByteInstantiation + Performance + + + ConsecutiveAppendsShouldReuse + Performance + + + ConsecutiveLiteralAppends + Performance + + + InefficientEmptyStringCheck + Performance + + + InefficientStringBuffering + Performance + + + InsufficientStringBufferDeclaration + Performance + + + IntegerInstantiation + Performance + + + LongInstantiation + Performance + + + OptimizableToArrayCall + Performance + + + RedundantFieldInitializer + Performance + + + ShortInstantiation + Performance + + + SimplifyStartsWith + Performance + + + StringInstantiation + Performance + + + StringToString + Performance + + + TooFewBranchesForASwitchStatement + Performance + + + UnnecessaryWrapperObjectCreation + Performance + + + UseArrayListInsteadOfVector + Performance + + + UseArraysAsList + Performance + + + UseIndexOfChar + Performance + + + UselessStringValueOf + Performance + + + UseStringBufferForStringAppends + Performance + + + UseStringBufferLength + Performance + + + ApexBadCrypto + Security + + + ApexCRUDViolation + Security + + + ApexCSRF + Security + + + ApexDangerousMethods + Security + + + ApexInsecureEndpoint + Security + + + ApexOpenRedirect + Security + + + ApexSharingViolations + Security + + + ApexSOQLInjection + Security + + + ApexSuggestUsingNamedCred + Security + + + ApexXSSFromEscapeFalse + Security + + + ApexXSSFromURLParam + Security + + + IframeMissingSrcAttribute + Security + + + NoUnsanitizedJSPExpression + Security + + + VfCsrf + Security + + + VfUnescapeEl + Security + + + false + true + true + diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index c4a0e3579c..44b1d65bc8 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -28,10 +28,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [The Spring @Controller and @RestController Annotations](http://www.baeldung.com/spring-controller-vs-restcontroller) - [Spring MVC @PathVariable with a dot (.) gets truncated](http://www.baeldung.com/spring-mvc-pathvariable-dot) - [A Quick Example of Spring Websockets’ @SendToUser Annotation](http://www.baeldung.com/spring-websockets-sendtouser) -- [Spring Boot Annotations](http://www.baeldung.com/spring-boot-annotations) -- [Spring Scheduling Annotations](http://www.baeldung.com/spring-scheduling-annotations) -- [Spring Web Annotations](http://www.baeldung.com/spring-mvc-annotations) -- [Spring Core Annotations](http://www.baeldung.com/spring-core-annotations) - [Using Spring ResponseEntity to Manipulate the HTTP Response](http://www.baeldung.com/spring-response-entity) - [Using Spring @ResponseStatus to Set HTTP Status Code](http://www.baeldung.com/spring-response-status) -- [Display RSS Feed with Spring MVC](http://www.baeldung.com/spring-mvc-rss-feed) diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 83f2556fe0..9d3e0ca1b2 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -5,70 +5,54 @@ spring-mvc-java 0.1-SNAPSHOT spring-mvc-java + war - parent-boot-2 + parent-spring-5 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2 + ../parent-spring-5 - - - org.springframework.boot - spring-boot-starter-thymeleaf + + org.springframework + spring-webmvc + ${spring.version} - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-devtools - - - org.springframework.boot - spring-boot-test - test - - - org.springframework.boot - spring-boot-starter-aop - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-websocket - - - - - com.fasterxml.jackson.core - jackson-databind - - - javax.servlet javax.servlet-api + 4.0.1 + + + javax.servlet.jsp + javax.servlet.jsp-api + 2.3.3 javax.servlet jstl + ${jstl.version} + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson-databind.version} org.aspectj aspectjrt + 1.9.1 org.aspectj aspectjweaver + 1.9.1 @@ -80,6 +64,7 @@ net.sourceforge.htmlunit htmlunit + 2.32 commons-logging @@ -104,10 +89,12 @@ com.jayway.jsonpath json-path test + 2.4.0 org.springframework spring-test + ${spring.version} test @@ -120,34 +107,29 @@ - org.hibernate + org.hibernate.validator hibernate-validator ${hibernate-validator.version} - - javax.el - javax.el-api - ${javax.el.version} - - - org.glassfish.web - javax.el - ${javax.el.version} - com.google.code.gson gson + 2.8.5 - - - - com.rometools - rome - ${rome.version} - + + org.springframework + spring-websocket + ${spring.version} + + + + org.springframework + spring-messaging + ${spring.version} + @@ -169,6 +151,7 @@ org.apache.maven.plugins maven-war-plugin + ${maven-war-plugin.version} false @@ -262,7 +245,7 @@ 3.0.9.RELEASE - 5.2.5.Final + 6.0.10.Final 5.1.40 @@ -281,24 +264,19 @@ 2.23 - 2.6 + 3.2.2 2.7 1.6.1 3.1.0 - 1.8.9 + 1.9.1 3.16-beta1 - - 1.10.0 - - 2.2.4 + 3.0.1-b06 - - com.baeldung.app.Application diff --git a/spring-mvc-java/src/main/java/com/baeldung/app/Application.java b/spring-mvc-java/src/main/java/com/baeldung/app/Application.java deleted file mode 100644 index 68d078de78..0000000000 --- a/spring-mvc-java/src/main/java/com/baeldung/app/Application.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.app; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; -import org.springframework.context.annotation.ComponentScan; - -@EnableAutoConfiguration -@ComponentScan(value = {"com.baeldung.web.controller"}, resourcePattern = "**/FileUploadController.class") -@SpringBootApplication -public class Application extends SpringBootServletInitializer { - - public static void main(final String[] args) { - SpringApplication.run(Application.class, args); - } -} \ No newline at end of file diff --git a/spring-mvc-java/src/main/java/com/baeldung/config/AppInitializer.java b/spring-mvc-java/src/main/java/com/baeldung/config/AppInitializer.java index 9cf6e384f1..eec12f466f 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/config/AppInitializer.java +++ b/spring-mvc-java/src/main/java/com/baeldung/config/AppInitializer.java @@ -14,13 +14,20 @@ public class AppInitializer implements WebApplicationInitializer { @Override public void onStartup(ServletContext container) throws ServletException { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); - context.setConfigLocation("org.baeldung.config"); + + context.scan("com.baeldung"); container.addListener(new ContextLoaderListener(context)); - ServletRegistration.Dynamic dispatcher = container.addServlet("java-servlet", new DispatcherServlet(context)); + ServletRegistration.Dynamic dispatcher = container.addServlet("mvc", new DispatcherServlet(context)); dispatcher.setLoadOnStartup(1); - dispatcher.addMapping("/java-servlet/*"); + dispatcher.addMapping("/"); + + // final MultipartConfigElement multipartConfigElement = new + // MultipartConfigElement(TMP_FOLDER, MAX_UPLOAD_SIZE, + // MAX_UPLOAD_SIZE * 2, MAX_UPLOAD_SIZE / 2); + // + // appServlet.setMultipartConfig(multipartConfigElement); } } diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/ApplicationConfig.java b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/ApplicationConfig.java deleted file mode 100644 index 261d5793dc..0000000000 --- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/ApplicationConfig.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.spring.web.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.servlet.view.JstlView; - -@EnableWebMvc -@Configuration -@ComponentScan(basePackages = { "com.baeldung.web.controller" }) -public class ApplicationConfig extends WebMvcConfigurerAdapter { - - public ApplicationConfig() { - super(); - } - - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - registry.addViewController("/").setViewName("index"); - } - - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/jsp/"); - bean.setSuffix(".jsp"); - return bean; - } -} \ No newline at end of file diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/ClientWebConfig.java b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/ClientWebConfig.java deleted file mode 100644 index de47f9f69e..0000000000 --- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/ClientWebConfig.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.baeldung.spring.web.config; - -import javax.servlet.ServletContext; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.MessageSource; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Description; -import org.springframework.context.support.ResourceBundleMessageSource; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.servlet.view.JstlView; -import org.thymeleaf.spring4.SpringTemplateEngine; -import org.thymeleaf.spring4.view.ThymeleafViewResolver; -import org.thymeleaf.templateresolver.ServletContextTemplateResolver; - -@EnableWebMvc -@Configuration -public class ClientWebConfig implements WebMvcConfigurer { - - public ClientWebConfig() { - super(); - } - - // API - - @Autowired - private ServletContext ctx; - - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - - registry.addViewController("/sample.html"); - } - - @Bean - public ViewResolver thymeleafViewResolver() { - final ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); - viewResolver.setTemplateEngine(templateEngine()); - viewResolver.setOrder(1); - return viewResolver; - } - - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); - bean.setOrder(0); - return bean; - } - - @Bean - @Description("Thymeleaf template resolver serving HTML 5") - public ServletContextTemplateResolver templateResolver() { - final ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(ctx); - templateResolver.setPrefix("/WEB-INF/templates/"); - templateResolver.setSuffix(".html"); - templateResolver.setTemplateMode("HTML5"); - return templateResolver; - } - - @Bean - @Description("Thymeleaf template engine with Spring integration") - public SpringTemplateEngine templateEngine() { - final SpringTemplateEngine templateEngine = new SpringTemplateEngine(); - templateEngine.setTemplateResolver(templateResolver()); - return templateEngine; - } - - @Bean - @Description("Spring message resolver") - public MessageSource messageSource() { - final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); - messageSource.setBasename("messages"); - return messageSource; - } - - @Override - public void addResourceHandlers(final ResourceHandlerRegistry registry) { - registry.addResourceHandler("/resources/**").addResourceLocations("/resources/"); - } - -} \ No newline at end of file diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/ContentManagementWebConfig.java b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/ContentManagementWebConfig.java deleted file mode 100644 index 498105ded1..0000000000 --- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/ContentManagementWebConfig.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.baeldung.spring.web.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.servlet.view.JstlView; - -@EnableWebMvc -@Configuration -public class ContentManagementWebConfig extends WebMvcConfigurerAdapter { - - public ContentManagementWebConfig() { - super(); - } - - // API - - @Override - public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) { - configurer.favorPathExtension(false).favorParameter(true).parameterName("mediaType").ignoreAcceptHeader(true).useJaf(false).defaultContentType(MediaType.APPLICATION_JSON).mediaType("xml", MediaType.APPLICATION_XML).mediaType("json", - MediaType.APPLICATION_JSON); - } - - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - registry.addViewController("/sample.html"); - } - - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); - bean.setOrder(0); - return bean; - } - -} diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java deleted file mode 100644 index 80ce22edd6..0000000000 --- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.baeldung.spring.web.config; - -import org.springframework.web.WebApplicationInitializer; -import org.springframework.web.context.ContextLoaderListener; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.context.support.GenericWebApplicationContext; -import org.springframework.web.servlet.DispatcherServlet; - -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRegistration; -import java.util.Set; - -public class MainWebAppInitializer implements WebApplicationInitializer { - - private static final String TMP_FOLDER = "/tmp"; - private static final int MAX_UPLOAD_SIZE = 5 * 1024 * 1024; // 5 MB - - /** - * Register and configure all Servlet container components necessary to power the web application. - */ - @Override - public void onStartup(final ServletContext sc) throws ServletException { - - // Create the 'root' Spring application context - final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); - root.scan("com.baeldung.spring.web.config"); - // root.getEnvironment().setDefaultProfiles("embedded"); - - sc.addListener(new ContextLoaderListener(root)); - - // Handles requests into the application - final ServletRegistration.Dynamic appServlet = sc.addServlet("mvc", new DispatcherServlet(new GenericWebApplicationContext())); - appServlet.setLoadOnStartup(1); - - // final MultipartConfigElement multipartConfigElement = new - // MultipartConfigElement(TMP_FOLDER, MAX_UPLOAD_SIZE, - // MAX_UPLOAD_SIZE * 2, MAX_UPLOAD_SIZE / 2); - // - // appServlet.setMultipartConfig(multipartConfigElement); - - final Set mappingConflicts = appServlet.addMapping("/"); - if (!mappingConflicts.isEmpty()) { - throw new IllegalStateException("'appServlet' could not be mapped to '/' due " + "to an existing mapping. This is a known issue under Tomcat versions " + "<= 7.0.14; see https://issues.apache.org/bugzilla/show_bug.cgi?id=51278"); - } - } - -} diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebConfig.java b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebConfig.java index 11be08a79d..191d721dfb 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebConfig.java +++ b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebConfig.java @@ -3,40 +3,105 @@ package com.baeldung.spring.web.config; import java.util.ArrayList; import java.util.List; +import javax.servlet.ServletContext; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.MessageSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Description; +import org.springframework.context.support.ResourceBundleMessageSource; import org.springframework.core.io.ClassPathResource; import org.springframework.http.MediaType; import org.springframework.http.converter.ByteArrayHttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.web.multipart.commons.CommonsMultipartResolver; import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; import org.springframework.web.servlet.view.ResourceBundleViewResolver; import org.springframework.web.servlet.view.XmlViewResolver; import org.springframework.web.util.UrlPathHelper; -import com.baeldung.excel.*; +import org.thymeleaf.spring4.SpringTemplateEngine; +import org.thymeleaf.spring4.view.ThymeleafViewResolver; +import org.thymeleaf.templateresolver.ServletContextTemplateResolver; + +import com.baeldung.excel.ExcelPOIHelper; -@Configuration @EnableWebMvc -@ComponentScan("com.baeldung.web") -public class WebConfig extends WebMvcConfigurerAdapter { +@Configuration +@ComponentScan(basePackages = { "com.baeldung.web.controller" }) +public class WebConfig implements WebMvcConfigurer { - public WebConfig() { - super(); + @Autowired + private ServletContext ctx; + + @Override + public void addViewControllers(final ViewControllerRegistry registry) { + registry.addViewController("/").setViewName("index"); + } + + @Bean + public ViewResolver thymeleafViewResolver() { + final ThymeleafViewResolver viewResolver = new ThymeleafViewResolver(); + viewResolver.setTemplateEngine(templateEngine()); + viewResolver.setOrder(1); + return viewResolver; } - // @Bean - // public StandardServletMultipartResolver multipartResolver() { - // return new StandardServletMultipartResolver(); - // } + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + bean.setOrder(0); + return bean; + } + @Bean + @Description("Thymeleaf template resolver serving HTML 5") + public ServletContextTemplateResolver templateResolver() { + final ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver(ctx); + templateResolver.setPrefix("/WEB-INF/templates/"); + templateResolver.setSuffix(".html"); + templateResolver.setTemplateMode("HTML5"); + return templateResolver; + } + + @Bean + @Description("Thymeleaf template engine with Spring integration") + public SpringTemplateEngine templateEngine() { + final SpringTemplateEngine templateEngine = new SpringTemplateEngine(); + templateEngine.setTemplateResolver(templateResolver()); + return templateEngine; + } + + @Bean + @Description("Spring message resolver") + public MessageSource messageSource() { + final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); + messageSource.setBasename("messages"); + return messageSource; + } + + @Override + public void addResourceHandlers(final ResourceHandlerRegistry registry) { + registry.addResourceHandler("/resources/**").addResourceLocations("/resources/"); + } + + @Override + public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) { + configurer.favorPathExtension(false).favorParameter(true).parameterName("mediaType").ignoreAcceptHeader(true).useRegisteredExtensionsOnly(false).defaultContentType(MediaType.APPLICATION_JSON).mediaType("xml", MediaType.APPLICATION_XML).mediaType("json", + MediaType.APPLICATION_JSON); + } @Bean(name = "multipartResolver") public CommonsMultipartResolver multipartResolver() { @@ -45,23 +110,7 @@ public class WebConfig extends WebMvcConfigurerAdapter { return multipartResolver; } - - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - registry.addViewController("/sample.html"); - } - - @Bean - public ViewResolver internalResourceViewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); - bean.setOrder(2); - return bean; - } - + @Bean public ViewResolver xmlViewResolver() { final XmlViewResolver bean = new XmlViewResolver(); @@ -112,5 +161,4 @@ public class WebConfig extends WebMvcConfigurerAdapter { public ExcelPOIHelper excelPOIHelper() { return new ExcelPOIHelper(); } - -} +} \ No newline at end of file diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketConfig.java b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketConfig.java index 93ec13da58..0793658e90 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketConfig.java +++ b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketConfig.java @@ -2,13 +2,13 @@ package com.baeldung.spring.web.config; import org.springframework.context.annotation.Configuration; import org.springframework.messaging.simp.config.MessageBrokerRegistry; -import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer; import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; import org.springframework.web.socket.config.annotation.StompEndpointRegistry; +import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; @Configuration @EnableWebSocketMessageBroker -public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer { +public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { @Override public void configureMessageBroker(final MessageBrokerRegistry config) { diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketSendToUserConfig.java b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketSendToUserConfig.java index 7f14380e5e..dbd52e20ba 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketSendToUserConfig.java +++ b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketSendToUserConfig.java @@ -6,9 +6,9 @@ import org.springframework.http.server.ServerHttpResponse; import org.springframework.http.server.ServletServerHttpRequest; import org.springframework.messaging.simp.config.MessageBrokerRegistry; import org.springframework.web.socket.WebSocketHandler; -import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer; import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; import org.springframework.web.socket.config.annotation.StompEndpointRegistry; +import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; import org.springframework.web.socket.server.support.DefaultHandshakeHandler; import javax.servlet.http.HttpSession; @@ -16,7 +16,7 @@ import java.util.Map; @Configuration @EnableWebSocketMessageBroker -public class WebSocketSendToUserConfig extends AbstractWebSocketMessageBrokerConfigurer { +public class WebSocketSendToUserConfig implements WebSocketMessageBrokerConfigurer { @Override public void configureMessageBroker(MessageBrokerRegistry config) { diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/SampleController.java b/spring-mvc-java/src/main/java/com/baeldung/web/controller/SampleController.java new file mode 100644 index 0000000000..c13986e005 --- /dev/null +++ b/spring-mvc-java/src/main/java/com/baeldung/web/controller/SampleController.java @@ -0,0 +1,13 @@ +package com.baeldung.web.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class SampleController { + @GetMapping("/sample") + public String showForm() { + return "sample"; + } + +} diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java index b628228b7e..384bd85ec6 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java +++ b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java @@ -20,12 +20,12 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; -import com.baeldung.spring.web.config.ApplicationConfig; +import com.baeldung.spring.web.config.WebConfig; import com.baeldung.spring.web.config.WebConfig; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration -@ContextConfiguration(classes = { ApplicationConfig.class, WebConfig.class }) +@ContextConfiguration(classes = { WebConfig.class, WebConfig.class }) public class GreetControllerIntegrationTest { @Autowired