Java Spring MVC web application configuration in NetBeans 8

When you create a Java Spring MVC web application or make changes to an existing one, it is important to know the location of configuration values.

Java package name

The Java package name is stored in

  • Every .java file
    • package MY_PACKAGE_NAME
  • pom.xml file
    • <configuration>
        <mainClass>com.objectdb.Enhancer</mainClass>
          <arguments>
            <argument>MY_PACKAGE_NAME.MY_MAIN_CLASS_NAME</argument>
          </arguments>
      </configuration>
  • .jsp file
    • <%@page import=”MY_PACKAGE_NAME.*”%>
    • <jsp:useBean id=”MY_BEAN_ID” type=”MY_PACKAGE_NAME.MY_DAO_CLASS_NAME” scope=”request” />

WAR file name

The name of the WAR fle is set in the

  • pom.xml file
    • <finalName>MY_WAR_FILE_NAME</finalName>

Add references to external classes

When you copy a class from another project, you need to add references to the imported external classes. When you build your project, the missing references will be in the output window.

————————————————————-
COMPILATION ERROR :
————————————————————-
webapp/twitter_keywordsRepository.java:[3,42] error: package org.springframework.data.repository does not exist

To add the reference to the project

  1. Click the error message link in the output window,
  2. Click the light bulb in the line of the error,
  3. In the context menu select Search Dependency at Maven Repositories for
  4. Select the recommended Maven repository, and click the Add button.

The references are stored in the

  • pom.xml file under
    • <dependencies>

 

 

 

Leave a comment

Your email address will not be published. Required fields are marked *