1

project structure

the only suggested solution for this error i get is to configure build path. I consider it is already everything at its place. please tell me the problem.

The error:

Multiple markers at this line - The type org.springframework.http.HttpStatus cannot be resolved. It is indirectly referenced from required .class files - The type org.springframework.web.method.support.HandlerMethodReturnValueHandler cannot be resolved. It is indirectly referenced from required .class files

i'm working on spring tool suite. here is my configuration file:

package com.health.config;
import java.io.IOException;

import javax.sql.DataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
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.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import com.health.dao.DAO;
import com.health.dao.DAOImpl;

@Configuration
@ComponentScan(basePackages="com.health")
@EnableWebMvc
@Component
public class AppConfig extends WebMvcConfigurerAdapter{

     @Override
        public void addResourceHandlers(ResourceHandlerRegistry registry) {
         registry.addResourceHandler("/resources/**").addResourceLocations("resources/");
        }


    @Bean
    public ViewResolver getViewResolver(){
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        resolver.setPrefix("/WEB-INF/views/");
        resolver.setSuffix(".jsp");
        return resolver;
    }

    @Bean
    public DataSource getDataSource() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql://localhost:3306/contactdb");
        dataSource.setUsername("root");
        dataSource.setPassword("welkinfort");
        return dataSource;
    }



    @Bean
    public DAO getDAO() {
        return new DAOImpl(getDataSource());
    }
}

here is my pom.xml:

<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 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.health</groupId>
<artifactId>healthcare</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>healthcare Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.38</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf -->
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>itextpdf</artifactId>
        <version>5.5.10</version>
    </dependency>

    <!-- jackson-annotations -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.8.1</version>
    </dependency>
    <!-- jackson-core -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.8.1</version>
    </dependency>
    <!-- jackson-databind -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.8.1</version>
    </dependency>

    <dependency>                                    <!-- file-upload -->
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3.1</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.3.7.RELEASE</version>
    </dependency>

    <dependency>                                <!-- spring-webmvc -->
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.1.8.RELEASE</version>
    </dependency>

    <dependency>                                <!-- spring-jdbc -->
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>4.2.5.RELEASE</version>
    </dependency>

    <dependency>                        <!--tomcat7-maven-plugin -->
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-catalina</artifactId>
        <version>7.0.47</version>
        <scope>provided</scope>
    </dependency>


    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

    <dependency>                                    <!-- jstl -->
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.1.2</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>4.0.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
<build>
    <finalName>healthcare</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <fork>true</fork>
                <executable>C:\Program Files\Java\jdk1.8.0_144\bin\javac</executable>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
        </plugin>
    </plugins>
</build>

Gurjot kaur
  • 145
  • 1
  • 13

1 Answers1

1

You are missing spring-web dependency. The org.springframework.http.HttpStatus is part of spring-web jar. Add this to your pom.xml:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>4.2.5.RELEASE</version>
</dependency>
Sangam Belose
  • 4,262
  • 8
  • 26
  • 48
  • adding this clashes with spring.jdbc – Gurjot kaur Nov 14 '17 at 06:11
  • i get these errors :1.The type org.springframework.jdbc.core.ResultSetExtractor cannot be resolved. It is indirectly referenced from required .class files 2.Multiple markers at this line - DriverManagerDataSource cannot be resolved to a type - DriverManagerDataSource cannot be resolved to a type – Gurjot kaur Nov 14 '17 at 06:11
  • I dont think this should cause issue with jdbc. Please do the maven update for your project. – Sangam Belose Nov 14 '17 at 06:13
  • right click on project --> maven --> update project. – Sangam Belose Nov 14 '17 at 06:14
  • i did some changes now these are the errors left: 1.Cannot change version of project facet Dynamic Web Module to 3.0. next is:One or more constraints have not been satisfied. both are Java EE Configuration Problems – Gurjot kaur Nov 14 '17 at 06:26
  • Its related with your servlet api version – Sangam Belose Nov 14 '17 at 06:29
  • Post your project structure..do you have web.xml? – Sangam Belose Nov 14 '17 at 06:30
  • https://i.stack.imgur.com/jPU9I.png :project structure. and i have not used web.xml. i use java classes with annotations instead of it – Gurjot kaur Nov 14 '17 at 06:47
  • change the project facets. since you are using the servlet 3.0+ spec you should use the appropriate facets. – Sangam Belose Nov 14 '17 at 07:05
  • Just search about this new issue..this might help..https://stackoverflow.com/questions/18122336/cannot-change-version-of-project-facet-dynamic-web-module-to-3-0 – Sangam Belose Nov 14 '17 at 07:06