Приложение закрывается, нужно это исрпавить

This commit is contained in:
DyCTaTOR 2024-04-28 18:14:20 +04:00
parent 2c00fd9487
commit ec87eb9ab4
7 changed files with 67 additions and 16 deletions

View File

@ -7,6 +7,18 @@ plugins {
group = 'com.example'
version = '0.0.1-SNAPSHOT'
defaultTasks 'bootRun'
jar {
enabled = false
}
bootJar {
archiveFileName = String.format('%s-%s.jar', rootProject.name, version)
}
assert System.properties['java.specification.version'] == '17' || '21' || '19'
java {
sourceCompatibility = '17'
}
@ -16,13 +28,16 @@ repositories {
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter:2.4.5'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0'
implementation 'org.modelmapper:modelmapper:3.2.0'
implementation 'org.postgresql-postgresql-runtime'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.postgresql:postgresql'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {

View File

@ -1,14 +1,29 @@
package com.example.autoservice;
import java.util.Objects;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class AutoserviceApplication implements CommandLineRunner{
import com.example.autoservice.clients.service.ClientsService;
@SpringBootApplication
public class AutoserviceApplication implements CommandLineRunner {
private final ClientsService clientsService;
public AutoserviceApplication(ClientsService clientsService) {
this.clientsService = clientsService;
}
public static void main(String[] args) {
SpringApplication.run(AutoserviceApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
if (args.length > 0 && Objects.equals("--populate", args[0])) {
}
}
}

View File

@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.example.demo.core.configuration.Constants;
import com.example.autoservice.core.configuration.Constants;
import com.example.autoservice.clients.service.ClientsService;
import com.example.autoservice.clients.model.ClientsEntity;
@ -24,11 +24,15 @@ public class ClientsController {
private final ClientsService clientsService;
private final ModelMapper modelMapper;
public DepartmentController(ClientsService clientsService, ModelMapper modelMapper) {
public ClientsController(ClientsService clientsService, ModelMapper modelMapper) {
this.clientsService = clientsService;
this.modelMapper = modelMapper;
}
public String showClientsPage(){
return "clients";
}
private ClientsDto toDto(ClientsEntity entity) {
return modelMapper.map(entity, ClientsDto.class);
}

View File

@ -1,5 +1,11 @@
package com.example.autoservice.clients.api;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;
public class ClientsDto{
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private Long id;

View File

@ -4,7 +4,7 @@ import java.util.Optional;
import org.springframework.data.repository.CrudRepository;
import com.example.autoservice.clients.model.ClientEntity;
import com.example.autoservice.clients.model.ClientsEntity;
public interface ClientsRepository extends CrudRepository<ClientsEntity, Long> {
}

View File

@ -8,13 +8,13 @@ import org.springframework.transaction.annotation.Transactional;
import com.example.autoservice.clients.model.ClientsEntity;
import com.example.autoservice.clients.repository.ClientsRepository;
import com.example.demo.core.error.NotFoundException;
import com.example.autoservice.core.error.NotFoundException;
@Service
public class ClientsService {
private final ClientsRepository repository;
public DepartmentService(ClientsRepository repository) {
public ClientsService(ClientsRepository repository) {
this.repository = repository;
}
@ -41,10 +41,10 @@ public class ClientsService {
public ClientsEntity update(Long id, ClientsEntity entity) {
final ClientsEntity existsEntity = get(id);
existsEntity.setFirst_Name(entity.getFirst_Name());
existsEntity.setLast_Name(entity.setLast_Name());
existsEntity.setMiddle_Name(entity.setMiddle_Name());
existsEntity.setDate_Birthday(entity.setDate_Birthday());
existsEntity.setPhone_Number(entity.setPhone_Number());
existsEntity.setLast_Name(entity.getLast_Name());
existsEntity.setMiddle_Name(entity.getMiddle_Name());
existsEntity.setDate_Birthday(entity.getDate_Birthday());
existsEntity.setPhone_Number(entity.getPhone_Number());
return repository.save(existsEntity);
}

View File

@ -1,7 +1,18 @@
spring.application.name=autoservice
spring.datasource.url=jdbc:postgresql://localhost:5432/autoservice
# Server
spring.main.banner-mode=off
server.port=8080
# Logger settings
# Available levels are: TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF
logging.level.com.example.autoservice=DEBUG
# JPA Settings
spring.datasource.url=jdbc:postgresql://192.168.56.101:5432/autoservice
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.open-in-view=false
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=update