fix non tanto fix di springBoot
This commit is contained in:
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -10,4 +10,7 @@
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="jpab" />
|
||||
</component>
|
||||
</project>
|
||||
1
.idea/vcs.xml
generated
1
.idea/vcs.xml
generated
@@ -2,6 +2,5 @@
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/prova" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
25
HELP.md
Normal file
25
HELP.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Getting Started
|
||||
|
||||
### Reference Documentation
|
||||
For further reference, please consider the following sections:
|
||||
|
||||
* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
|
||||
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/3.0.6/maven-plugin/reference/html/)
|
||||
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/3.0.6/maven-plugin/reference/html/#build-image)
|
||||
* [Spring Data JPA](https://docs.spring.io/spring-boot/docs/3.0.6/reference/htmlsingle/#data.sql.jpa-and-spring-data)
|
||||
* [Spring Web](https://docs.spring.io/spring-boot/docs/3.0.6/reference/htmlsingle/#web)
|
||||
* [Spring Session](https://docs.spring.io/spring-session/reference/)
|
||||
* [Rest Repositories](https://docs.spring.io/spring-boot/docs/3.0.6/reference/htmlsingle/#howto.data-access.exposing-spring-data-repositories-as-rest)
|
||||
|
||||
### Guides
|
||||
The following guides illustrate how to use some features concretely:
|
||||
|
||||
* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/)
|
||||
* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
|
||||
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
|
||||
* [Building REST services with Spring](https://spring.io/guides/tutorials/rest/)
|
||||
* [Accessing data with MySQL](https://spring.io/guides/gs/accessing-data-mysql/)
|
||||
* [Accessing JPA Data with REST](https://spring.io/guides/gs/accessing-data-rest/)
|
||||
* [Accessing Neo4j Data with REST](https://spring.io/guides/gs/accessing-neo4j-data-rest/)
|
||||
* [Accessing MongoDB Data with REST](https://spring.io/guides/gs/accessing-mongodb-data-rest/)
|
||||
|
||||
118
pom.xml
118
pom.xml
@@ -1,55 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.0.6</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>ch</groupId>
|
||||
<artifactId>progetto152</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>progetto152</name>
|
||||
<description>Progetto 152</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-rest</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>prova</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>2.7.11</version>
|
||||
</dependency>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
<version>2.7.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.28</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>javax.persistence-api</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>5.3.20.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>5.3.27</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package ch.progetto152;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/users")
|
||||
public class Controller {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<List<User>> getAllUsers() {
|
||||
List<User> users = userService.getAllUsers();
|
||||
return new ResponseEntity<>(users, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<User> getUserById(@PathVariable("id") Long id) {
|
||||
User user = userService.getUserById(id);
|
||||
if (user != null) {
|
||||
return new ResponseEntity<>(user, HttpStatus.OK);
|
||||
} else {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<User> createUser(@RequestBody User user) {
|
||||
User createdUser = userService.createUser(user);
|
||||
return new ResponseEntity<>(createdUser, HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<User> updateUser(@PathVariable("id") Long id, @RequestBody User user) {
|
||||
User updatedUser = userService.updateUser(id, user);
|
||||
if (updatedUser != null) {
|
||||
return new ResponseEntity<>(updatedUser, HttpStatus.OK);
|
||||
} else {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> deleteUser(@PathVariable("id") Long id) {
|
||||
boolean deleted = userService.deleteUser(id);
|
||||
if (deleted) {
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
} else {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package ch.progetto152;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Main.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Controller controller() {
|
||||
return new Controller();
|
||||
}
|
||||
|
||||
}
|
||||
20
src/main/java/ch/progetto152/Progetto152Application.java
Normal file
20
src/main/java/ch/progetto152/Progetto152Application.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package ch.progetto152;
|
||||
|
||||
import ch.progetto152.controller.UserController;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Progetto152Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Progetto152Application.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public UserController newController() {
|
||||
return new UserController();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package ch.progetto152.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import jakarta.persistence.*;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package ch.progetto152.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "LocationVisited", schema = "Progetto152", catalog = "")
|
||||
public class LocationVisited{
|
||||
|
||||
@Id
|
||||
@Basic
|
||||
@Column(name = "userId")
|
||||
private int userId;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package ch.progetto152.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "User", schema = "Progetto152", catalog = "")
|
||||
public class User {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Id
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ch.progetto152.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
|
||||
32
src/main/java/ch/progetto152/services/UserService.java
Normal file
32
src/main/java/ch/progetto152/services/UserService.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package ch.progetto152.services;
|
||||
|
||||
|
||||
import ch.progetto152.entity.User;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
|
||||
|
||||
public List<User> getAllUsers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public User getUserByIdService(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public User createUser(User user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public User updateUser(Long id, User user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean deleteUser(Long id) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
4
src/main/resources/application.properties
Normal file
4
src/main/resources/application.properties
Normal file
@@ -0,0 +1,4 @@
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/Progetto152
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=Admin123
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<!DOCTYPE hibernate-configuration PUBLIC
|
||||
"-//Hibernate/Hibernate Configuration DTD//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
|
||||
|
||||
<hibernate-configuration>
|
||||
|
||||
<!-- a SessionFactory instance listed as /jndi/name -->
|
||||
<session-factory>
|
||||
<property name="hibernate.connection.username">root</property>
|
||||
|
||||
<property name="hibernate.connection.password">Admin123</property>
|
||||
|
||||
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/ICT</property>
|
||||
|
||||
<property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property>
|
||||
|
||||
<property name="hibernate.show_sql">false</property>
|
||||
|
||||
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
|
||||
|
||||
|
||||
</session-factory>
|
||||
|
||||
</hibernate-configuration>
|
||||
@@ -1,43 +0,0 @@
|
||||
drop database if exists Progetto152;
|
||||
create database if not exists Progetto152;
|
||||
use Progetto152;
|
||||
|
||||
|
||||
|
||||
create table if not exists Location
|
||||
(
|
||||
id int auto_increment not null,
|
||||
location varchar(255) not null unique,
|
||||
region varchar(3) not null,
|
||||
lat double not null,
|
||||
lon double not null,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
create table if not exists Waypoints
|
||||
(
|
||||
id int not null auto_increment,
|
||||
name varchar(10) not null,
|
||||
lat double not null,
|
||||
lon double not null,
|
||||
description varchar(1000) not null,
|
||||
img varchar(1000) not null,
|
||||
LocationId int not null,
|
||||
primary key (id),
|
||||
foreign key (LocationId) references Location (id)
|
||||
);
|
||||
|
||||
create table if not exists User(
|
||||
id int not null auto_increment,
|
||||
name varchar(45) not null,
|
||||
username varchar(100) not null,
|
||||
password varchar(100) not null,
|
||||
primary key (id)
|
||||
);
|
||||
|
||||
create table if not exists LocationVisited(
|
||||
userId int not null,
|
||||
locationid int not null,
|
||||
foreign key (userId) references User(id),
|
||||
foreign key (locationid) references Location(id)
|
||||
)
|
||||
@@ -1,16 +0,0 @@
|
||||
get:
|
||||
progetto152/locations
|
||||
progetto152/location/{location}
|
||||
progetto152/waypoints/{location}
|
||||
progetto152/waypoint/{location}/{id}
|
||||
maybe:
|
||||
progetto152/user/{user}
|
||||
progetto152/user/{user}/location
|
||||
|
||||
post:
|
||||
progetto152/location
|
||||
progetto152/waypoint
|
||||
maybe:
|
||||
progetto152/user
|
||||
progetto152/user/{user}/location
|
||||
|
||||
Reference in New Issue
Block a user