3월 2023 | ||||||
---|---|---|---|---|---|---|
일 | 월 | 화 | 수 | 목 | 금 | 토 |
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
단물이 나는 샘은 가장 먼저 퍼내어 마르게 되고 키가 큰 나무는 가장 먼저 잘리게 된다. 모든 것이 쓸모가 있으면 자기의 장점으로 인해 몸을 망치게 된다. -묵자
★★★ 깃허브 소스 trip.festival 참조 할것
https://github.com/braverokmc79/springboot-green2209S_16
1. net.sf.log4jdbc.DriverSpy 사용하고 있으면 원래 datasource.driverClassName 으로 변경 처리 한다.
2.
package trip.festival; import javax.sql.DataSource; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionFactoryBean; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.Bean; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.scheduling.annotation.EnableScheduling; //exclude = { SecurityAutoConfiguration.class } 사용시 시큐리티 자동로그인 설정을 배제한다 @SpringBootApplication() @MapperScan(value = { "trip.festival.model.dao.mapper" }) @EnableScheduling public class Application extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(Application.class); } public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Bean public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean(); sessionFactory.setDataSource(dataSource); Resource[] res = new PathMatchingResourcePatternResolver().getResources("classpath:mapper/*Mapper.xml"); sessionFactory.setMapperLocations(res); return sessionFactory.getObject(); } }
3.pom.xml
<?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 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>2.7.6</version> <relativePath /> <!-- lookup parent from repository --> </parent> <groupId>trip.festival</groupId> <artifactId>trip-festival</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>system</name> <description>trip.festival</description> <properties> <java.version>11</java.version> </properties> <dependencies>
<build> <finalName>${artifactId}</finalName> <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> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.2</version> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> <defaultGoal>install</defaultGoal> </build>
4. 빌드
[Spring Boot] Maven 빌드
https://hgko1207.github.io/2021/03/09/springboot-1/
5. Tomcat 서버에 Spring Boot WAR 배포
https://recordsoflife.tistory.com/392
2023-02-27 21:42:14
Window server에 jar 배포하기
Window server에 jar 배포하기
스프링부트로 개발된 프로젝트를 window os 서버에 배포하는 과정을 정리했다.
배포방법에는 foreground와 background배포가 있는데 전자의 방법은 콘솔창을 닫으면 해당 프로세스도 종료되는 방식이다. 서버는 콘솔창이 닫히더라도 진행되어야 하기 때문에 후자의 방법이 권장된다.
[TIP] 콘솔창을 열 때 해당 디렉토리의 주소에 cmd를 입력하면 현재 디렉토리가 터미널에 열리게 된다.
foreground 배포
java -jar JAR-NAME.jar
background 배포
javaw -jar JAR-NAME.jar
프로세스 종료
// javaw 이름으로 실행중인 프로세스를 검색한다 tasklist /svc | findstr javaw // 검색된 프로세스의 id값을 이용해 프로세스를 종료한다 taskkill /pid PID /f taskkill /pid 3778 /f2023-02-27 20:34:21
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | <sec:authorize access= "isAnonymous()" ><!-- 로그인 안한 유저 --> <c:choose> <c:when test= "${not empty q.password}" > <a href= "#" class = "pop_klover" onclick= "pop_klover(this, '#klover-layer')" data-board_id= "${q.board_id}" data-subject= "${q.subject}" data-href= "board/qna/qnaDetail?board_id=${q.board_id}&pageNum=${page.currentPage}&field=${field}&word=${word}" >${q.subject}</a> </c:when> <c:otherwise> <a href= "board/qna/qnaDetail?board_id=${q.board_id}&pageNum=${page.currentPage}&field=${field}&word=${word}" >${q.subject}</a> </c:otherwise> </c:choose> </sec:authorize> <sec:authorize access= "isAuthenticated()" > <sec:authorize access= "hasRole('ROLE_MEMBER')" ><!-- 일반유저 --> <c:choose> <c:when test= "${not empty q.password}" > <a href= "#" class = "pop_klover" onclick= "pop_klover(this, '#klover-layer')" data-board_id= "${q.board_id}" data-subject= "${q.subject}" data-href= "board/qna/qnaDetail?board_id=${q.board_id}&pageNum=${page.currentPage}&field=${field}&word=${word}" >${q.subject}</a> </c:when> <c:otherwise> <a href= "board/qna/qnaDetail?board_id=${q.board_id}&pageNum=${page.currentPage}&field=${field}&word=${word}" >${q.subject}</a> </c:otherwise> </c:choose> </sec:authorize> <sec:authorize access= "hasRole('ROLE_ADMIN')" > <!-- 관리자 --> <a href= "board/qna/qnaDetail?board_id=${q.board_id}&pageNum=${page.currentPage}&field=${field}&word=${word}" >${q.subject}</a> </sec:authorize> </sec:authorize> |
2022-11-16 14:49:12
UTF 한글 깨짐
@GetMapping("/listall/{prodNum}") public ResponseEntity<?> listSellerReviewAll(@PathVariable Integer prodNum , PageMaker pageMaker) throws Exception{ log.info(" pageMaker {}" , pageMaker.getPage()); pageMaker.setProdNum(prodNum); pageMaker.setPerPageNum(5); //전체 갯수 가져오기 int totalCount=serllerReviewService.listSellerReviewAllTotalCount(pageMaker); pageMaker.setTotalCount(totalCount); List<SellerReviewVO> serList=serllerReviewService.listSellerReviewAll(pageMaker); Map<String, Object> map=new LinkedHashMap<String, Object>(); String pagination=pageMaker.bootStrapPagingSearchHTML("/api/review/listall/"+prodNum); map.put("code","success"); map.put("totalCount", totalCount); map.put("pageMaker", pageMaker); map.put("serList", serList); map.put("pagination", pagination); log.info( "list : {}" , serList.size() ); HttpHeaders responHeaders=new HttpHeaders(); responHeaders.add("Content-Type", "text/html;charset=utf-8"); return new ResponseEntity(new ObjectMapper().writeValueAsString(map), responHeaders, HttpStatus.OK); }
2022-11-14 23:34:57
그래들 WAR 파일로 배포
1 . SpringBootServletInitializer 추가
다음과 같은 형식으로 변경
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @SpringBootApplication public class Application extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(PcwApplication.class, args); } protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(Application.class); } }
2. build.gradle 변경
id 'war' 추가
plugins { id 'org.springframework.boot' version '2.7.0' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' id 'eclipse' id 'war' }
war 플러그인 추가
apply plugin:'war'
bootWar 추가
bootWar { archiveName 'ROOT.war' archiveBaseName = "ROOT" archiveFileName = "ROOT.war" archiveVersion = "0.0.0" }
spring-boot-starter-tomcat 추가
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
build.gradle 전체 샘플 예
plugins { id 'org.springframework.boot' version '2.7.5' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' id 'eclipse' id 'war' } group = 'com.sample' version = '0.0.1-SNAPSHOT' apply plugin:'war' sourceCompatibility = '11' configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } bootWar { archiveName 'ROOT.war' archiveBaseName = "ROOT" archiveFileName = "ROOT.war" archiveVersion = "0.0.0" } dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.2' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' runtimeOnly 'mysql:mysql-connector-java' annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' implementation 'org.apache.tomcat.embed:tomcat-embed-jasper' implementation 'javax.servlet:jstl:1.2' implementation 'org.jsoup:jsoup:1.15.1' implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.4' implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16' providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' } tasks.named('test') { useJUnitPlatform() }
3. Gradle Tasks 메뉴 에서 bootWar 를 클릭해서 빌드
Navigator 메뉴와 Gradle Tasks 메뉴가 없다면
window -> show view 에서 Navigator 메뉴와 Gradle Tasks 를 연다.
Gradle Tasks 메뉴 에서 bootWar 를 클릭
Navigator 에서 build -> libs 디렉토리에 빌드된 ROOT.war 파일이 생성 된다.
2022-11-13 03:17:17
macaronics.net 는 그어떠한 동영상, 이미지, 파일등을 직접적으로 업로드 제공을 하지 않습니다. 페이스북, 트위터 등 각종 SNS 처럼 macaronics.net 는 웹서핑을 통하여 각종 페이지위치등을 하이퍼링크, 다이렉트링크, 직접링크등으로 링크된 페이지 주소만을 수집 저장하여 제공하고 있습니다. 저장된 각각의 주소에 연결된 페이지등은 그 페이지에서 제공하는 "서버, 사이트" 상황에 따라 페이지와 내용이 삭제 중단 될 수 있으며 macaronics.net 과는 어떠한 연관 관련이 없음을 알려드립니다. 또한, 저작권에 관련된 문제있는 글이나 기타 저작권에 관련된 문제가 있는 것은 연락주시면 바로 삭제해 드리겠습니다.
댓글 ( 0)
댓글 남기기