728x90

출처

추가된 디스트 Volume 확인

X
user@localhost:~

bluesanta@bluesanta-desktop:~$ sudo fdisk -l
Disk /dev/loop0: 63.45 MiB, 66531328 bytes, 129944 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
 
 
Disk /dev/loop1: 4 KiB, 4096 bytes, 8 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
 
 
Disk /dev/loop2: 349.7 MiB, 366682112 bytes, 716176 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
 
 
Disk /dev/loop3: 237.21 MiB, 248729600 bytes, 485800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
 
 
Disk /dev/loop4: 91.69 MiB, 96141312 bytes, 187776 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
 
 
Disk /dev/loop5: 53.26 MiB, 55844864 bytes, 109072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
 
 
Disk /dev/sda: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Samsung SSD 870 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: C4F503A5-7CD4-4AC3-AE41-7BBD9B61E399
 
Device       Start       End   Sectors   Size Type
/dev/sda1     2048   1050623   1048576   512M EFI System
/dev/sda2  1050624 976771071 975720448 465.3G Linux filesystem
 
 
Disk /dev/sdb: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: WDC WD20SPZX-22C
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x6c571c01
 
Device     Boot Start        End    Sectors  Size Id Type
/dev/sdb1        2048 3907029167 3907027120  1.8T 83 Linux

파일시스템 생성

X
user@localhost:~

[user@localhost]$ sudo mkfs.ext4 /dev/sdb mke2fs
mke2fs 1.46.5 (30-Dec-2021)
mkfs.ext4: invalid blocks 'mke2fs' on device '/dev/sdb'
bluesanta@bluesanta-desktop:~$ sudo mkfs.ext4 /dev/sdb
mke2fs 1.46.5 (30-Dec-2021)
Found a dos partition table in /dev/sdb
Proceed anyway? (y,N) y
Discarding device blocks: done                            
Creating filesystem with 488378646 4k blocks and 122101760 inodes
Filesystem UUID: b6b293bc-ea55-46c0-81d4-ebd2f9d74d96
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000, 214990848
 
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (262144 blocks): 
done
Writing superblocks and filesystem accounting information: done 

mount 받을 디렉토리 생성

X
user@localhost:~

[user@localhost]$ sudo mkdir /bluesanta

mount 하기

X
user@localhost:~

[user@localhost]$ sudo mount /dev/sdb /bluesanta

mount 확인

X
user@localhost:~

[user@localhost]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           1.6G  1.4M  1.6G   1% /run
/dev/sda2       457G   12G  422G   3% /
tmpfs           7.7G     0  7.7G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
/dev/sda1       511M  6.1M  505M   2% /boot/efi
tmpfs           1.6G   36K  1.6G   1% /run/user/120
tmpfs           1.6G   36K  1.6G   1% /run/user/1000
/dev/sdb        1.8T   28K  1.7T   1% /bluesanta

unmount 하기

X
user@localhost:~

[user@localhost]$ sudo umount /bluesanta

unmount 확인

X
user@localhost:~

[user@localhost]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           1.6G  1.4M  1.6G   1% /run
/dev/sda2       457G   12G  422G   3% /
tmpfs           7.7G     0  7.7G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
/dev/sda1       511M  6.1M  505M   2% /boot/efi
tmpfs           1.6G   36K  1.6G   1% /run/user/120
tmpfs           1.6G   36K  1.6G   1% /run/user/1000

자동 mount

출처 : Ubuntu 14.04에 새로운 하드디스크 추가 및 포맷후 자동 마운트 설정

UUID 확인

X
user@localhost:~

[user@localhost]$ sudo blkid
/dev/sda2: UUID="39078512-c2b4-4394-9e19-cfdb594ffae0" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="9a1d3cca-9d52-431b-8b49-ccc350a568a0"
/dev/loop1: TYPE="squashfs"
/dev/sdb: UUID="b6b293bc-ea55-46c0-81d4-ebd2f9d74d96" BLOCK_SIZE="4096" TYPE="ext4"
/dev/loop4: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop0: TYPE="squashfs"
/dev/sda1: UUID="B19D-6F5C" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="77fa62a1-e620-49b2-9e5c-f62bd9edc72d"
/dev/loop5: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"

fstab 파일에 파티션 추가

X
user@localhost:~

[user@localhost]$ sudo vi /etc/fstab

# 파티션 추가 
UUID=b6b293bc-ea55-46c0-81d4-ebd2f9d74d96       /bluesanta      ext4    defaults        0       0
728x90
728x90

출처

기존 OpenCV 버전 제거

OpenCV 설치확인

X
user@localhost:~

orangepi@orangepi5plus:~$ pkg-config --modversion opencv
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found

OpenCV 패키지 삭제

X
user@localhost:~

orangepi@orangepi5plus:~$ sudo apt purge libopencv* python-opencv
orangepi@orangepi5plus:~$ sudo apt autoremove

기존에 설치된 opencv 라이브러리를 삭제

X
user@localhost:~

orangepi@orangepi5plus:~$ sudo find /usr/local/ -name "*opencv*" -exec rm {} \;

OS 업데이트, 업그레이드

X
user@localhost:~

orangepi@orangepi5plus:~$ sudo apt update && sudo apt upgrade

OpenCV 빌드 관련 도구 설치

X
user@localhost:~

orangepi@orangepi5plus:~$ sudo apt install build-essential cmake cmake-gui

OpenCV 관련 라이브러리 설치

X
user@localhost:~

orangepi@orangepi5plus:~$ sudo apt install libjpeg-dev libtiff5-dev libavcodec-dev libavformat-dev libswscale-dev libxvidcore-dev libx264-dev libxine2-dev libv4l-dev v4l-utils libpng-dev

GStreamer 관련 패키지 설치

X
user@localhost:~

orangepi@orangepi5plus:~$ sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly

GTK 관련 라이브러리 설치

X
user@localhost:~

orangepi@orangepi5plus:~$ sudo apt install libgtk2.0-dev

GTK 관련 라이브러리 설치 오류시

OpenGL 라이브러리 설치

X
user@localhost:~

orangepi@orangepi5plus:~$ sudo apt install mesa-utils libgtkgl2.0-dev libgtkglext1-dev libgtk3.0-cil-dev

OpenCV 최적화를 위해 사용되는 라이브러리

X
user@localhost:~

orangepi@orangepi5plus:~$ sudo apt install libatlas-base-dev gfortran libeigen3-dev

Python 설치

X
user@localhost:~

orangepi@orangepi5plus:~$ sudo apt install python2.7-dev python3-dev python3-numpy

OpenCV 4.1.1 다운로드

OpenCV 4.1.1 소스 다운로드

X
user@localhost:~

orangepi@orangepi5plus:~$ mkdir OpenCV
orangepi@orangepi5plus:~$ cd OpenCV
orangepi@orangepi5plus:~/OpenCV$ wget -O opencv.zip https://github.com/opencv/opencv/archive/4.5.5.zip
orangepi@orangepi5plus:~/OpenCV$ unzip opencv.zip
orangepi@orangepi5plus:~/OpenCV$ wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.5.5.zip
orangepi@orangepi5plus:~/OpenCV$ unzip opencv_contrib.zip

디렉토리명 변경

X
user@localhost:~

orangepi@orangepi5plus:~/OpenCV$ cd opencv-4.5.5
orangepi@orangepi5plus:~/OpenCV/opencv-4.5.5$ mkdir build
orangepi@orangepi5plus:~/OpenCV/opencv-4.5.5$ cd build

OpenCV 컴파일

CMake 실행

X
user@localhost:~

orangepi@orangepi5plus:~/OpenCV/opencv-4.5.5/build$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \
  -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.5.5/modules -D OPENCV_GENERATE_PKGCONFIG=ON \
  -D BUILD_opencv_java=OFF -D BUILD_opencv_python3=ON -D WITH_OPENMP=OFF -D WITH_GSTREAMER_0_10=OFF \
  -D WITH_VTK=OFF -D WITH_LIBV4L=ON -D WITH_OPENMP=ON -D WITH_OPENGL=ON -D WITH_TBB=ON \
  -D BUILD_SHARED_LIBS=ON -D ENABLE_PIC=ON -D WITH_ARITH_DEC=ON -D WITH_ARITH_ENC=ON \
  -D WITH_FFMPEG=ON -D WITH_GSTREAMER=ON -D WITH_IMGCODEC_HDR=ON -D WITH_IMGCODEC_PXM=ON \
  -D WITH_IMGCODEC_SUNRASTER=ON -D WITH_JASPER=ON -D WITH_JPEG=ON -D WITH_LAPACK=ON \
  -D WITH_PNG=ON -D WITH_QT=ON -D WITH_PTHREADS_PF=ON -D WITH_TIFF=ON -D WITH_WEBP=ON \
  -D WITH_GTK=ON -D BUILD_PNG=ON -D WITH_OPENCL=ON ..
 
. ... 생략 ... 
 
-- General configuration for OpenCV 4.5.5 =====================================
--   Version control:               unknown
-- 
--   Extra modules:
--     Location (extra):            /home/orangepi/OpenCV/opencv_contrib-4.5.5/modules
--     Version control (extra):     unknown
-- 
--   Platform:
--     Timestamp:                   2023-11-05T00:40:39Z
--     Host:                        Linux 5.10.110-rockchip-rk3588 aarch64
--     CMake:                       3.22.1
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/gmake
--     Configuration:               RELEASE
-- 
--   CPU/HW features:
--     Baseline:                    NEON FP16
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ standard:                11
--     C++ Compiler:                /usr/bin/c++  (ver 11.4.0)
--     C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG
--     C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -fopenmp -g  -O0 -DDEBUG -D_DEBUG
--     C Compiler:                  /usr/bin/cc
--     C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fopenmp -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fopenmp -g  -O0 -DDEBUG -D_DEBUG
--     Linker flags (Release):      -Wl,--gc-sections -Wl,--as-needed  
--     Linker flags (Debug):        -Wl,--gc-sections -Wl,--as-needed  
--     ccache:                      NO
--     Precompiled headers:         NO
--     Extra dependencies:          dl m pthread rt
--     3rdparty dependencies:
-- 
--   OpenCV modules:
--     To be built:                 alphamat aruco barcode bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python3 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab wechat_qrcode xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv hdf java julia matlab ovis python2 sfm viz
--     Applications:                tests perf_tests apps
--     Documentation:               NO
--     Non-free algorithms:         NO
-- 
--   GUI:                           GTK2
--     QT:                          NO
--     GTK+:                        YES (ver 2.24.33)
--       GThread :                  YES (ver 2.72.4)
--       GtkGlExt:                  YES (ver 1.2.0)
--     OpenGL support:              YES (/usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so)
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)
--     JPEG:                        /usr/lib/aarch64-linux-gnu/libjpeg.so (ver 80)
--     WEBP:                        build (ver encoder: 0x020f)
--     PNG:                         /lib/libpng12.so (ver 1.6.37)
--     TIFF:                        /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.3.0)
--     JPEG 2000:                   build (ver 2.4.0)
--     OpenEXR:                     /usr/lib/aarch64-linux-gnu/libImath-2_5.so /usr/lib/aarch64-linux-gnu/libIlmImf-2_5.so /usr/lib/aarch64-linux-gnu/libIex-2_5.so /usr/lib/aarch64-linux-gnu/libHalf-2_5.so /usr/lib/aarch64-linux-gnu/libIlmThread-2_5.so (ver 2_5)
--     HDR:                         YES
--     SUNRASTER:                   YES
--     PXM:                         YES
--     PFM:                         YES
-- 
--   Video I/O:
--     DC1394:                      YES (2.2.6)
--     FFMPEG:                      YES
--       avcodec:                   YES (58.134.100)
--       avformat:                  YES (58.76.100)
--       avutil:                    YES (56.70.100)
--       swscale:                   YES (5.9.100)
--       avresample:                NO
--     GStreamer:                   YES (1.20.3)
--     v4l/v4l2:                    YES (linux/videodev2.h)
-- 
--   Parallel framework:            TBB (ver 2021.5 interface 12050)
-- 
--   Trace:                         YES (with Intel ITT)
-- 
--   Other third-party libraries:
--     Lapack:                      NO
--     Eigen:                       YES (ver 3.4.0)
--     Custom HAL:                  YES (carotene (ver 0.0.1))
--     Protobuf:                    build (3.19.1)
-- 
--   OpenCL:                        YES (no extra features)
--     Include path:                /home/orangepi/OpenCV/opencv-4.5.5/3rdparty/include/opencl/1.2
--     Link libraries:              Dynamic load
-- 
--   Python 3:
--     Interpreter:                 /usr/bin/python3 (ver 3.10.12)
--     Libraries:                   /usr/lib/aarch64-linux-gnu/libpython3.10.so (ver 3.10.12)
--     numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver 1.21.5)
--     install path:                lib/python3.10/dist-packages/cv2/python-3.10
-- 
--   Python (for build):            /usr/bin/python2.7
-- 
--   Java:                          
--     ant:                         NO
--     JNI:                         NO
--     Java wrappers:               NO
--     Java tests:                  NO
-- 
--   Install to:                    /usr/local
-- -----------------------------------------------------------------
-- 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/orangepi/OpenCV/opencv-4.5.5/build

CPU 코어 개수 확인

X
user@localhost:~

orangepi@orangepi5plus:~/OpenCV/opencv-4.5.5/build$ grep -c processor /proc/cpuinfo
8

OpenCV 컴파일

X
user@localhost:~

orangepi@orangepi5plus:~/OpenCV/opencv-4.5.5/build$ make -j8

OpenCV 설치

X
user@localhost:~

orangepi@orangepi5plus:~/OpenCV/opencv-4.5.5/build$ sudo make install
orangepi@orangepi5plus:~/OpenCV/opencv-4.5.5/build$ sudo ldconfig

OpenCV 설치 확인

파이썬

X
user@localhost:~

orangepi@orangepi5plus:~/OpenCV/opencv-4.5.5/build$ python
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.5.5'
>>> exit()

C++

#include "opencv2/opencv.hpp"

using namespace cv;
using namespace std;

int main( int argc, char** argv ) {
  cout << "OpenCV version : " << CV_VERSION << endl;
  cout << "Major version : " << CV_MAJOR_VERSION << endl;
  cout << "Minor version : " << CV_MINOR_VERSION << endl;
  cout << "Subminor version : " << CV_SUBMINOR_VERSION << endl; 
}
X
user@localhost:~

orangepi@orangepi5plus:~$ g++ version_check.cpp -o version_check -std=c++11 `pkg-config --cflags --libs opencv4`
orangepi@orangepi5plus:~$ ./version_check
OpenCV version : 4.5.5
Major version : 4
Minor version : 5
Subminor version : 5

728x90
728x90

출처

소스

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <DHT.h>

const char *ssid = "iptime";
const char *password = "password";
IPAddress ip(192, 168, 0, 122); // 임시 IP 주소 설정
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
#define DHTPIN 4          // DHT 센서의 핀 번호
#define DHTTYPE DHT11     // DHT11 센서 사용

DHT dht(DHTPIN, DHTTYPE);

ESP8266WebServer server(80);

void setup() {
  Serial.begin(921600);
  delay(10);

  dht.begin();
  WiFi.config(ip, gateway, subnet); // 임시 IP 설정
 
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP()); // WiFi의 로컬 IP 주소 출력
    Serial.println("Connecting to WiFi...");
  }
  
  Serial.println("Connected to WiFi");
 
  server.on("/", handleRoot);
  server.begin();
}

void loop() {
  server.handleClient();
}

void handleRoot() {
  float temperature = dht.readTemperature(); // 온도 값을 읽음

  String html = "<html><body>";
  html += "<h1>web server</h1>";
  html += "<p>now temp: " + String(temperature) + "C</p>";
  html += "</body></html>";

  server.send(200, "text/html", html); // 클라이언트에 응답 전송
}
728x90
728x90

출처

MSYS2 설치

https://www.msys2.org/ 설치본 다운로드

git 설치

$ pacman -S git

컴파일 도구 설치

$ pacman -S diffutils make pkg-config yasm mingw-w64-x86_64-autotools

x64 Native Tools Command Prompt for VS 2022 실행(msvc 환경)후 mingw 환경 실행

C:\Program Files\Microsoft Visual Studio\2022\Enterprise>D:\msys64\msys2_shell.cmd -msys -use-full-path

소스 다운로드

nv-codec-headers 소스 다운로드

$ git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git

ffmpeg 소스 다운로드

$ git clone https://git.ffmpeg.org/ffmpeg.git

PREFIX 경로 /usr 설정

$ make install PREFIX=/usr
sed 's#@@PREFIX@@#D:/msys64/usr#' ffnvcodec.pc.in > ffnvcodec.pc
install -m 0755 -d '/usr/include/ffnvcodec'
install -m 0644 include/ffnvcodec/*.h '/usr/include/ffnvcodec'
install -m 0755 -d '/usr/lib/pkgconfig'
install -m 0644 ffnvcodec.pc '/usr/lib/pkgconfig'

환경 설정(.bash_profile 마지막에 추가)

export LIB=/C/Program\ Files/Microsoft\ Visual\ Studio/2022/Enterprise/VC/Tools/MSVC/14.36.32532/lib/x64:/C/Program\ Files/Microsoft\ Visual\ Studio/2022/Enterprise/SDK/ScopeCppSDK/vc15/SDK/lib
export LIBPATH=/C/Program\ Files/Microsoft\ Visual\ Studio/2022/Enterprise/VC/Tools/MSVC/14.36.32532/lib/x64:/C/Program\ Files/Microsoft\ Visual\ Studio/2022/Enterprise/SDK/ScopeCppSDK/vc15/SDK/lib

configure 실행

$ ./configure --enable-nonfree --disable-shared --enable-cuda-nvcc --enable-libnpp --toolchain=msvc --extra-cflags=-I../nv_sdk --extra-cflags=-I../nv_sdk/include/ --extra-ldflags=-libpath:../nv_sdk --extra-ldflags=-libpath:../nv_sdk/lib/x64 --arch=x86_64

ffmpeg 컴파일

X
user@localhost:~

[user@localhost]$ make -j$(nproc)

확인

X
user@localhost:~

[user@localhost]$ ffmpeg -version
ffmpeg version N-111746-gd53acf452f Copyright (c) 2000-2023 the FFmpeg developers
built with Microsoft (R) C/C++ 최적화 컴파일러 버전 19.36.32537(x64)
configuration: --enable-nonfree --disable-shared --enable-cuda-nvcc --enable-libnpp --toolchain=ms
vc --enable-filter=drawtext --extra-cflags=-I../nv_sdk --extra-cflags=-I../nv_sdk/include/ --extra
-ldflags='-libpath:../nv_sdk' --extra-ldflags='-libpath:../nv_sdk/lib/x64' --arch=x86_64
libavutil      58. 16.101 / 58. 16.101
libavcodec     60. 23.100 / 60. 23.100
libavformat    60. 10.100 / 60. 10.100
libavdevice    60.  2.101 / 60.  2.101
libavfilter     9. 10.100 /  9. 10.100
libswscale      7.  3.100 /  7.  3.100
libswresample   4. 11.100 /  4. 11.100

ffmpeg 설치

X
user@localhost:~

bluesanta@DESKTOP-PJENQJG MSYS ~/ffmpeg
[user@localhost]$ make install
INSTALL doc/ffmpeg.1
INSTALL doc/ffprobe.1
INSTALL doc/ffmpeg-all.1
INSTALL doc/ffprobe-all.1
INSTALL doc/ffmpeg-utils.1
INSTALL doc/ffmpeg-scaler.1
INSTALL doc/ffmpeg-resampler.1
INSTALL doc/ffmpeg-codecs.1
INSTALL doc/ffmpeg-bitstream-filters.1
INSTALL doc/ffmpeg-formats.1
INSTALL doc/ffmpeg-protocols.1
INSTALL doc/ffmpeg-devices.1
INSTALL doc/ffmpeg-filters.1
INSTALL doc/libavutil.3
INSTALL doc/libswscale.3
INSTALL doc/libswresample.3
INSTALL doc/libavcodec.3
INSTALL doc/libavformat.3
INSTALL doc/libavdevice.3
INSTALL doc/libavfilter.3
INSTALL doc/ffmpeg.1
INSTALL doc/ffprobe.1
INSTALL doc/ffmpeg-all.1
INSTALL doc/ffprobe-all.1
INSTALL doc/ffmpeg-utils.1
INSTALL doc/ffmpeg-scaler.1
INSTALL doc/ffmpeg-resampler.1
INSTALL doc/ffmpeg-codecs.1
INSTALL doc/ffmpeg-bitstream-filters.1
INSTALL doc/ffmpeg-formats.1
INSTALL doc/ffmpeg-protocols.1
INSTALL doc/ffmpeg-devices.1
INSTALL doc/ffmpeg-filters.1
INSTALL doc/libavutil.3
INSTALL doc/libswscale.3
INSTALL doc/libswresample.3
INSTALL doc/libavcodec.3
INSTALL doc/libavformat.3
INSTALL doc/libavdevice.3
INSTALL doc/libavfilter.3
INSTALL install-progs-yes
INSTALL ffmpeg.exe
INSTALL ffprobe.exe
INSTALL presets/libvpx-1080p.ffpreset
INSTALL presets/libvpx-1080p50_60.ffpreset
INSTALL presets/libvpx-360p.ffpreset
INSTALL presets/libvpx-720p.ffpreset
INSTALL presets/libvpx-720p50_60.ffpreset
INSTALL doc/ffprobe.xsd
INSTALL doc/examples/avio_http_serve_files.c
INSTALL doc/examples/avio_list_dir.c
INSTALL doc/examples/avio_read_callback.c
INSTALL doc/examples/decode_audio.c
INSTALL doc/examples/decode_filter_audio.c
INSTALL doc/examples/decode_filter_video.c
INSTALL doc/examples/decode_video.c
INSTALL doc/examples/demux_decode.c
INSTALL doc/examples/encode_audio.c
INSTALL doc/examples/encode_video.c
INSTALL doc/examples/extract_mvs.c
INSTALL doc/examples/filter_audio.c
INSTALL doc/examples/hw_decode.c
INSTALL doc/examples/mux.c
INSTALL doc/examples/qsv_decode.c
INSTALL doc/examples/qsv_transcode.c
INSTALL doc/examples/remux.c
INSTALL doc/examples/resample_audio.c
INSTALL doc/examples/scale_video.c
INSTALL doc/examples/show_metadata.c
INSTALL doc/examples/transcode.c
INSTALL doc/examples/transcode_aac.c
INSTALL doc/examples/vaapi_encode.c
INSTALL doc/examples/vaapi_transcode.c
INSTALL doc/examples/README
INSTALL doc/examples/Makefile
INSTALL doc/examples/avio_http_serve_files.c
INSTALL doc/examples/avio_list_dir.c
INSTALL doc/examples/avio_read_callback.c
INSTALL doc/examples/decode_audio.c
INSTALL doc/examples/decode_filter_audio.c
INSTALL doc/examples/decode_filter_video.c
INSTALL doc/examples/decode_video.c
INSTALL doc/examples/demux_decode.c
INSTALL doc/examples/encode_audio.c
INSTALL doc/examples/encode_video.c
INSTALL doc/examples/extract_mvs.c
INSTALL doc/examples/filter_audio.c
INSTALL doc/examples/hw_decode.c
INSTALL doc/examples/mux.c
INSTALL doc/examples/qsv_decode.c
INSTALL doc/examples/qsv_transcode.c
INSTALL doc/examples/remux.c
INSTALL doc/examples/resample_audio.c
INSTALL doc/examples/scale_video.c
INSTALL doc/examples/show_metadata.c
INSTALL doc/examples/transcode.c
INSTALL doc/examples/transcode_aac.c
INSTALL doc/examples/vaapi_encode.c
INSTALL doc/examples/vaapi_transcode.c
INSTALL doc/examples/README
INSTALL doc/examples/Makefile
INSTALL libavdevice/libavdevice.a
INSTALL libavfilter/libavfilter.a
INSTALL libavformat/libavformat.a
INSTALL libavcodec/libavcodec.a
INSTALL libswresample/libswresample.a
INSTALL libswscale/libswscale.a
INSTALL libavutil/libavutil.a
INSTALL libavdevice/avdevice.h
INSTALL libavdevice/version.h
INSTALL libavdevice/version_major.h
INSTALL libavdevice/libavdevice.pc
INSTALL libavfilter/avfilter.h
INSTALL libavfilter/buffersink.h
INSTALL libavfilter/buffersrc.h
INSTALL libavfilter/version.h
INSTALL libavfilter/version_major.h
INSTALL libavfilter/libavfilter.pc
INSTALL libavformat/avformat.h
INSTALL libavformat/avio.h
INSTALL libavformat/version.h
INSTALL libavformat/version_major.h
INSTALL libavformat/libavformat.pc
INSTALL libavcodec/ac3_parser.h
INSTALL libavcodec/adts_parser.h
INSTALL libavcodec/avcodec.h
INSTALL libavcodec/avdct.h
INSTALL libavcodec/avfft.h
INSTALL libavcodec/bsf.h
INSTALL libavcodec/codec.h
INSTALL libavcodec/codec_desc.h
INSTALL libavcodec/codec_id.h
INSTALL libavcodec/codec_par.h
INSTALL libavcodec/d3d11va.h
INSTALL libavcodec/defs.h
INSTALL libavcodec/dirac.h
INSTALL libavcodec/dv_profile.h
INSTALL libavcodec/dxva2.h
INSTALL libavcodec/jni.h
INSTALL libavcodec/mediacodec.h
INSTALL libavcodec/packet.h
INSTALL libavcodec/qsv.h
INSTALL libavcodec/vdpau.h
INSTALL libavcodec/version.h
INSTALL libavcodec/version_major.h
INSTALL libavcodec/videotoolbox.h
INSTALL libavcodec/vorbis_parser.h
INSTALL libavcodec/xvmc.h
INSTALL libavcodec/libavcodec.pc
INSTALL libswresample/swresample.h
INSTALL libswresample/version.h
INSTALL libswresample/version_major.h
INSTALL libswresample/libswresample.pc
INSTALL libswscale/swscale.h
INSTALL libswscale/version.h
INSTALL libswscale/version_major.h
INSTALL libswscale/libswscale.pc
INSTALL libavutil/adler32.h
INSTALL libavutil/aes.h
INSTALL libavutil/aes_ctr.h
INSTALL libavutil/ambient_viewing_environment.h
INSTALL libavutil/attributes.h
INSTALL libavutil/audio_fifo.h
INSTALL libavutil/avassert.h
INSTALL libavutil/avstring.h
INSTALL libavutil/avutil.h
INSTALL libavutil/base64.h
INSTALL libavutil/blowfish.h
INSTALL libavutil/bprint.h
INSTALL libavutil/bswap.h
INSTALL libavutil/buffer.h
INSTALL libavutil/cast5.h
INSTALL libavutil/camellia.h
INSTALL libavutil/channel_layout.h
INSTALL libavutil/common.h
INSTALL libavutil/cpu.h
INSTALL libavutil/crc.h
INSTALL libavutil/csp.h
INSTALL libavutil/des.h
INSTALL libavutil/detection_bbox.h
INSTALL libavutil/dict.h
INSTALL libavutil/display.h
INSTALL libavutil/dovi_meta.h
INSTALL libavutil/downmix_info.h
INSTALL libavutil/encryption_info.h
INSTALL libavutil/error.h
INSTALL libavutil/eval.h
INSTALL libavutil/fifo.h
INSTALL libavutil/file.h
INSTALL libavutil/frame.h
INSTALL libavutil/hash.h
INSTALL libavutil/hdr_dynamic_metadata.h
INSTALL libavutil/hdr_dynamic_vivid_metadata.h
INSTALL libavutil/hmac.h
INSTALL libavutil/hwcontext.h
INSTALL libavutil/hwcontext_cuda.h
INSTALL libavutil/hwcontext_d3d11va.h
INSTALL libavutil/hwcontext_drm.h
INSTALL libavutil/hwcontext_dxva2.h
INSTALL libavutil/hwcontext_qsv.h
INSTALL libavutil/hwcontext_mediacodec.h
INSTALL libavutil/hwcontext_opencl.h
INSTALL libavutil/hwcontext_vaapi.h
INSTALL libavutil/hwcontext_videotoolbox.h
INSTALL libavutil/hwcontext_vdpau.h
INSTALL libavutil/hwcontext_vulkan.h
INSTALL libavutil/imgutils.h
INSTALL libavutil/intfloat.h
INSTALL libavutil/intreadwrite.h
INSTALL libavutil/lfg.h
INSTALL libavutil/log.h
INSTALL libavutil/lzo.h
INSTALL libavutil/macros.h
INSTALL libavutil/mathematics.h
INSTALL libavutil/mastering_display_metadata.h
INSTALL libavutil/md5.h
INSTALL libavutil/mem.h
INSTALL libavutil/motion_vector.h
INSTALL libavutil/murmur3.h
INSTALL libavutil/opt.h
INSTALL libavutil/parseutils.h
INSTALL libavutil/pixdesc.h
INSTALL libavutil/pixelutils.h
INSTALL libavutil/pixfmt.h
INSTALL libavutil/random_seed.h
INSTALL libavutil/rc4.h
INSTALL libavutil/rational.h
INSTALL libavutil/replaygain.h
INSTALL libavutil/ripemd.h
INSTALL libavutil/samplefmt.h
INSTALL libavutil/sha.h
INSTALL libavutil/sha512.h
INSTALL libavutil/spherical.h
INSTALL libavutil/stereo3d.h
INSTALL libavutil/threadmessage.h
INSTALL libavutil/time.h
INSTALL libavutil/timecode.h
INSTALL libavutil/timestamp.h
INSTALL libavutil/tree.h
INSTALL libavutil/twofish.h
INSTALL libavutil/uuid.h
INSTALL libavutil/version.h
INSTALL libavutil/video_enc_params.h
INSTALL libavutil/xtea.h
INSTALL libavutil/tea.h
INSTALL libavutil/tx.h
INSTALL libavutil/film_grain_params.h
INSTALL libavutil/video_hint.h
INSTALL libavutil/avconfig.h
INSTALL libavutil/ffversion.h
INSTALL libavutil/libavutil.pc

lame 빌드 실패 이력

X
user@localhost:~

[user@localhost]$ export AR=lib.exe
[user@localhost]$ export LD=link.exe
[user@localhost]$ export MP3LAME_VERSION=3.100
[user@localhost]$ export MP3LAME_URL="https://sourceforge.net/projects/lame/files/lame/$MP3LAME_VERSION/lame-$MP3LAME_VERSION.tar.gz/download"
[user@localhost]$ export MP3LAME_SHA256=ddfe36cab873794038ae2c1210557ad34857a4b6bdc515785d1da9e175b1da1e
[user@localhost]$ wget -O lame.tar.gz "$MP3LAME_URL" && echo "$MP3LAME_SHA256 lame.tar.gz" | sha256sum --status -c -
[user@localhost]$ tar xfz lame.tar.gz
[user@localhost]$ cd lame-3.100/
[user@localhost]$ ./configure --prefix=/mingw64 --disable-shared --enable-static
[user@localhost]$ make
make  all-recursive
make[1]: Entering directory '/home/bluesanta/ffmpeg_sources/lame-3.100'
Making all in mpglib
make[2]: Entering directory '/home/bluesanta/ffmpeg_sources/lame-3.100/mpglib'
/bin/sh ../libtool  --tag=CC   --mode=link /home/bluesanta/ffmpeg_sources/lame-3.100/compile cl.exe     -o libmpgdecoder.la  common.lo dct64_i386.lo decode_i386.lo interface.lo layer1.lo layer2.lo layer3.lo tabinit.lo
libtool: link: lib.exe cru .libs/libmpgdecoder.a  common.obj dct64_i386.obj decode_i386.obj interface.obj layer1.obj layer2.obj layer3.obj tabinit.obj
Microsoft (R) Library Manager Version 14.36.32537.0
Copyright (C) Microsoft Corporation.  All rights reserved.
 
LINK : fatal error LNK1181: 'cru' 입력 파일을 열 수 없습니다.
make[2]: *** [Makefile:411: libmpgdecoder.la] Error 157
make[2]: Leaving directory '/home/bluesanta/ffmpeg_sources/lame-3.100/mpglib'
make[1]: *** [Makefile:452: all-recursive] Error 1
make[1]: Leaving directory '/home/bluesanta/ffmpeg_sources/lame-3.100'
make: *** [Makefile:381: all] Error 2

728x90
728x90

출처

커밋 로그 확인

C:\project>git log --oneline
d09c1ef (HEAD -> master, origin/master) JSON 라이브러리 참조 추가
01eac01 멤버 권한 체크 메뉴 변경
80a8d17 Member 관련 ID 검사 조건 수정

git reset : 커밋 취소하기 (변경된 파일 되돌리기 - 추가된 파일은 삭제 하지 않음)

C:\project>git reset --hard d09c1ef
Updating files: 100% (1865/1865), done.
HEAD is now at d09c1ef JSON 라이브러리 참조 추가

git status : 현재 상태 확인 (추가된 파일 확인)

C:\project>git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        kanji/kanji-jouyou.json

nothing added to commit but untracked files present (use "git add" to track)

삭제 대상(Untracked files) 목록 확인

C:\project>git clean -f
Removing kanji/kanji-jouyou.json​

Untracked files 파일 삭제

C:\project>git clean -n
Would remove kanji/kanji-jouyou.json
728x90
728x90

출처

Maven pom.xml 설정

Maven 배포시 프로파일 선택 옵션 : mvn clean package -P prod

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
      <resource>
        <directory>src/main/resources/bluexmas-${profile}</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
    </resources>
    
    <!-- 생략 -->  
  </build>
  
  <profiles>
    <profile>
      <id>dev</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <profile>dev</profile>
      </properties>
    </profile>
    <profile>
      <id>local</id>
      <properties>
        <profile>local</profile>
      </properties>
    </profile>
    <profile>
      <id>prod</id>
        <properties>
          <profile>prod</profile>
      </properties>
    </profile>
  </profiles>

src\main\resources\bluexmas-dev\config\config.properties

username=test
password=test!!

@Configuration 클래스 (PropertyConfig.java)

@Bean(name="config") : Bean 객체 config 이름으로 스프링 컨테이너에 로딩

package com.bluexmas.config;

import java.io.IOException;

import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;

@Configuration
public class PropertyConfig {

	@Bean(name="config")
	public static PropertiesFactoryBean config() throws IOException {
		PropertiesFactoryBean pspc = new PropertiesFactoryBean();
		Resource[] resources = new PathMatchingResourcePatternResolver()
				.getResources("classpath:/config/config.properties");
		pspc.setLocations(resources);
		return pspc;
	}
}

Config 값 참조

@Resource(name="config") : config 이름의 Properties 객체 참조
@Value("#{config['username']}") : config 이름의 Properties 객체에서 username 값 참조

package com.bluexmas.controller;

import java.util.Properties;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class SampleController {
	
	@Resource(name="config")
	private Properties config;
	
	@Value("#{config['username']}")
	private String username;
	
	@ResponseBody
	@RequestMapping("/sample")
	public String sample() {
		System.out.println("username.1 = " + config.get("username"));
		System.out.println("username.2 = " + username);
		
		String data = "@ResponseBody 어노테이션을 통해 반환";
		return data;
	}
	
}
728x90
728x90

출처

Maven pom.xml 설정

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>5.2.3.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
    <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter</artifactId>
      <version>2.1.1</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.6</version>
    </dependency>
    <!-- mybatis -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.4.2</version>
    </dependency>
    <!-- mybatis spring -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>1.3.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.18.4</version>
      <scope>provided</scope>
    </dependency>

application.properties

## MySQL
spring.datasource.driver-class-name=org.gjt.mm.mysql.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test_db?user=user1&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull&useSSL=false
spring.datasource.username=user1
spring.datasource.password=user1!!

# 패키지 result tpye에 명을 생략할 수 있도록 alias 설정
mybatis.type-aliases-package=com.bluexmas.domain

# model 프로퍼티 camel case 설정
# mybatis.configuration.map-underscore-to-camel-case=true

# Mybatis mapper 위치 설정
mybatis.mapper-locations=classpath:/**/**.xml

Domain

package com.bluexmas.domain;

import java.sql.Date;

import lombok.Data;

@Data
public class Notice {
	
	// pk
	private int notice_no;
	
	private String notice_type;
	private String title;
	private String content;
	private int hit;
	private int reg_no;
	private Date reg_dt;
	private Date upt_dt;
	private String del_yn;
	private Date del_dt;
	
}

Persistence

package com.bluexmas.persistence;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;

import com.bluexmas.domain.Notice;

@Mapper
public interface NoticeMapper {

	public Notice selectNotice(Map<String, Object> params);

	public int insertNotice(Notice notice);

	public int updateNotice(Notice notice);

	public int deleteNotice(Map<String, Object> params);

	public int getCount();

	public List listNotice(Map<String, Object> map);

}

Service

package com.bluexmas.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bluexmas.domain.Notice;
import com.bluexmas.persistence.NoticeMapper;

@Service
public class NoticeService {

	@Autowired
	private NoticeMapper noticeMapper;

	public Notice selectNotice(int noticeNo) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("notice_no",noticeNo);
		return noticeMapper.selectNotice(params);
	}

	public int insertNotice(Notice notice) {
		return noticeMapper.insertNotice(notice);
	}

	public int updateNotice(Notice notice) {
		return noticeMapper.updateNotice(notice);
	}

	public int deleteNotice(int noticeNo) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("notice_no",noticeNo);
		return noticeMapper.deleteNotice(params);
	}

	public int getCount() {
		return noticeMapper.getCount();
	}

	public List listNotice() throws Exception {
		Map<String, Object> params = new HashMap<String, Object>();
		return noticeMapper.listNotice(params);
	}
}

src\main\mybatis\com\bluexmas\persistence\NoticeMapper.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.bluexmas.persistence.NoticeMapper">

	<!-- selectNotice -->
	<select id="selectNotice" parameterType="map" resultType="com.bluexmas.domain.Notice">
		select *
		  from notice
		 where notice_no = #{notice_no}
	</select>

	<!-- insertNotice -->
	<insert id="insertNotice" parameterType="com.bluexmas.domain.Notice" statementType="PREPARED">
		insert into notice(
		    <trim suffixOverrides=",">
		      <if test="notice_type != null">notice_type ,</if>
		      <if test="title != null">title ,</if>
		      <if test="content != null">content ,</if>
		      <if test="hit != null">hit ,</if>
		      <if test="reg_no != null">reg_no ,</if>
		      <if test="reg_dt != null">reg_dt ,</if>
		      <if test="upt_dt != null">upt_dt ,</if>
		      <if test="del_yn != null">del_yn ,</if>
		      <if test="del_dt != null">del_dt ,</if>
		    </trim>
		    ) values (
		    <trim suffixOverrides=",">
		      <if test="notice_type != null">#{notice_type, jdbcType=VARCHAR} ,</if>
		      <if test="title != null">#{title, jdbcType=VARCHAR} ,</if>
		      <if test="content != null">#{content, jdbcType=VARCHAR} ,</if>
		      <if test="hit != null">#{hit, jdbcType=INTEGER} ,</if>
		      <if test="reg_no != null">#{reg_no, jdbcType=INTEGER} ,</if>
		      <if test="reg_dt != null">#{reg_dt, jdbcType=TIMESTAMP} ,</if>
		      <if test="upt_dt != null">#{upt_dt, jdbcType=TIMESTAMP} ,</if>
		      <if test="del_yn != null">#{del_yn, jdbcType=VARCHAR} ,</if>
		      <if test="del_dt != null">#{del_dt, jdbcType=TIMESTAMP} ,</if>
		    </trim>
		)
		<selectKey keyProperty="notice_no" resultType="Integer">
			SELECT LAST_INSERT_ID()
		</selectKey>
	</insert>

	<!-- updateNotice -->
	<update id="updateNotice" parameterType="com.bluexmas.domain.Notice" statementType="PREPARED">
		update notice
		    <trim prefix="SET" suffixOverrides=",">
		      <if test="notice_type != null">notice_type = #{notice_type, jdbcType=VARCHAR} ,</if>
		      <if test="title != null">title = #{title, jdbcType=VARCHAR} ,</if>
		      <if test="content != null">content = #{content, jdbcType=VARCHAR} ,</if>
		      <if test="hit != null">hit = #{hit, jdbcType=INTEGER} ,</if>
		      <if test="reg_no != null">reg_no = #{reg_no, jdbcType=INTEGER} ,</if>
		      <if test="reg_dt != null">reg_dt = #{reg_dt, jdbcType=TIMESTAMP} ,</if>
		      <if test="upt_dt != null">upt_dt = #{upt_dt, jdbcType=TIMESTAMP} ,</if>
		      <if test="del_yn != null">del_yn = #{del_yn, jdbcType=VARCHAR} ,</if>
		      <if test="del_dt != null">del_dt = #{del_dt, jdbcType=TIMESTAMP} ,</if>
		    </trim>
		 where notice_no = #{notice_no}
	</update>

	<!-- deleteNotice -->
	<delete id="deleteNotice" parameterType="map" statementType="PREPARED">
		delete from notice
		 where notice_no = #{notice_no}
	</delete>

	<!-- getCount -->
	<select id="getCount" resultType="int">
		select count(*)
		  from notice
	</select>

	<!-- listNotice -->
	<select id="listNotice" parameterType="map" resultType="com.bluexmas.domain.Notice">
		select a.*
		  FROM notice a
	</select>

</mapper>

Controller 소스

package com.bluexmas.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bluexmas.domain.Notice;
import com.bluexmas.service.NoticeService;

@Controller
public class NoticeController {

	@Autowired
	private NoticeService noticeService;
	
	@RequestMapping(value="/notice_list.do", method=RequestMethod.GET)
	public @ResponseBody Map<String, Object> notice_list(ModelMap modelMap) throws Exception {
		//
		Map<String, Object> result = new HashMap<> ();
		
		//
		List<Notice> listNotice = noticeService.listNotice();
		result.put("notice_list", listNotice);
		
		//
		return result;
	}
}

실행

728x90
728x90

출처

Maven pom.xml 설정

    <!-- 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.2.4.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-tomcat -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
      <version>3.1.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-jasper -->
    <dependency>
      <groupId>org.apache.tomcat.embed</groupId>
      <artifactId>tomcat-embed-jasper</artifactId>
      <version>9.0.31</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>

Spring Boot JSP ViewResolver 구성

JSP 파일 위치를 해결하려면 두 가지 방법을 사용할 수 있습니다.

1) application.properties에 항목 추가

#http port
server.port=7070

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

2) JSP 페이지를 제공하도록 InternalResourceViewResolver 구성

package com.bluexmas.config;
 
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
 
@Configuration
@EnableWebMvc
@ComponentScan
public class MvcConfiguration extends WebMvcConfigurerAdapter
{
  @Override
  public void configureViewResolvers(ViewResolverRegistry registry) {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix("/WEB-INF/view/");
    resolver.setSuffix(".jsp");
    resolver.setViewClass(JstlView.class);
    registry.viewResolver(resolver);
  }
}

Controller 소스

package com.bluexmas.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class SampleController {
	
	/*
	 * 스프링부트에서의 jsp 호출 테스트
	 */
	@RequestMapping("/jspSample")
	public String jspSample(ModelMap modelMap) throws Exception {
		modelMap.put("name", "홍길동");

		List jspSample = new ArrayList();
		jspSample.add("국어 : 100점");
		jspSample.add("수학 : 90점");
		jspSample.add("영어 : 75점");

		modelMap.put("list", jspSample);
		
		return "jspSample";
	}
}

View(JSP) - src\main\webapp\WEB-INF\jsp\jspSample.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 
<html>
<head>
<meta charset="UTF-8">
    <title>JSP Sample Page</title>
</head>
    <body>
 
       <div>[${name}]님의 시험성적입니다.</div>
 
        <c:forEach var="item" items="${list}">
         ${item} <br />
        </c:forEach>
 
    </body>
</html>

실행

728x90

+ Recent posts