작성
·
341
0
인텔리제이 사용이 미숙합니다 ...
프로젝트를 따라하면서 지금 뭐가잘못된건지 잘 모르겠지만 tomcat연결이 되지 않습니다!!
지금까지 한 프로젝트 깃에 올려두었습니다ㅠㅠ 혹시 해결 가능할까요 선생님
답변 3
0
build.gradle
plugins {
id 'org.springframework.boot' version '2.4.5'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'jpaTest'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
testCompileOnly 'junit:junit:4.12'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.1.0'
}
test {
useJUnitPlatform()
}
application.yml
spring:
h2:
console:
enabled: true
path: /h2-console
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:testdb
username: sa
password:
jpa:
open-in-view: false
hibernate:
ddl-auto: create
properties:
hibernate:
show_sql: true
format_sql: true
logging:
level:
org.hibernate.SQL: debug
ItemRepository
@Repository
@RequiredArgsConstructor
public class ItemRepository {
private final EntityManager em;
//private final Item item;
public void save(Item item) {
if(item.getId() == null) {
em.persist(item);
} else{
em.merge(item);
}
}
public Item findOne(Long id) {
return em.find(Item.class, id);
}
public List<Item> findAll() {
return em.createQuery("select i from Item i", Item.class)
.getResultList();
}
}
실행
이렇게만 바꿔도 일단 동작은 합니다.
근데 코드 구현되지 않은 파일을 화면에 사용한다고 선언해놓아서 발생하는 문제들이 발생합니다.
그것과 관련해서 질문을 주실 경우 코드를 작성하고 재 질문 남겨주시길 바랍니다.
0
코드 확인해보았습니다.
질문에는 강의를 따라하다 톰캣이 안된다고 하셨는데
DB는 강의에서 사용하는 H2가아닌 마리아DB이고 톰캣도 스프링부트가 제공하는 내장톰캣이 아니고
따로 설치하신것 같더라구요. 마리아 DB와 설치한 톰캣에서의 동작이 제대로 되었으면 하시는건가요?
질문을 명확히, "어디까지 제대로 진행했었는데 어떤 것을 진행 하니 막히더라" 라는 것을 정확히 해주시길 바랍니다.