Categories
Development Java

Unable to resolve java build / Spring

First Thing to say, I am a relatively inexperienced programmer.

My task is to import a given gradle project into Spring Boot Tool Suite (sts). I have already download springboot cli, java, gradle. & In the past, I was able to run spring perfectly on another project, unfortunately I had to get my hard drive replaced, so I lost a considerable amount of downloads.

Nonetheless, my issue is two-parted. Firstly, my tool suite (ide? It’s basically eclipse) does not recognize my project as a a java project, I have tried many options & the only was to fix that portion is to hardcode org.eclipse.core.javabuilder within the buildCommand tag in my .project file, which I don’t remember doing for my last project.

Here is the directory tree of the backend folder(don’t concern with the frontend)

.
├── build.gradle
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
    ├── main
    │   ├── java
    │   │   └── ca
    │   │       └── mcgill
    │   │           └── ecse321
    │   │               └── eventregistration
    │   │                   ├── EventRegistrationApplication.java
    │   │                   ├── controller
    │   │                   │   ├── ApiError.java
    │   │                   │   ├── EventRegistrationRestController.java
    │   │                   │   └── RestExceptionHandler.java
    │   │                   ├── dao
    │   │                   │   ├── EventRegistrationRepository.java
    │   │                   │   ├── EventRepository.java
    │   │                   │   ├── PersonRepository.java
    │   │                   │   └── RegistrationRepository.java
    │   │                   ├── dto
    │   │                   │   ├── EventDto.java
    │   │                   │   ├── PersonDto.java
    │   │                   │   └── RegistrationDto.java
    │   │                   ├── model
    │   │                   │   ├── Event.java
    │   │                   │   ├── Person.java
    │   │                   │   ├── Registration.java
    │   │                   │   └── RegistrationManager.java
    │   │                   └── service
    │   │                       └── EventRegistrationService.java
    │   └── resources
    │       └── application.properties
    └── test
        └── java
            └── ca
                └── mcgill
                    └── ecse321
                        └── eventregistration
                            └── service
                                ├── event
                                │   └── TestCinema.java
                                ├── payment
                                │   ├── TestPaymentWithCreditCard.java
                                │   ├── TestPaymentWithCreditCardData.java
                                │   └── TestUtils.java
                                └── role
                                    ├── PromoterRoleTestData.java
                                    └── TestPromoterRole.java

Additionally, Here it my build.gradle file

buildscript {
	ext {
		springBootVersion = '2.1.2.RELEASE'
	}
	repositories {
		mavenCentral()
	}
	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
	}
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
	mavenCentral()
}
 
dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	runtimeOnly 'org.postgresql:postgresql'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

This fixes my java problem, but I still cannot get it running as a spring boot application.

Please help as I am not sure where to continue!!! I need to be able to run this project as a spring boot application for backend services, as I will then be tasked with connecting it to frontend services with vue.js. (Don’t worry i got that part)!

Here is my EventRegistration.java file as well

package ca.mcgill.ecse321.eventregistration;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.SpringApplication;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

@RestController
@SpringBootApplication
public class EventRegistrationApplication {

	public static void main(String[] args) {
		SpringApplication.run(EventRegistrationApplication.class, args);
	}

	@RequestMapping("/")
	public String greeting() {
		return "ECSE321 Event Registration Application - Backend base URL.\n"
				+ "Use the API methods to interact with the backend!";
	}
}

Leave a Reply

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