반응형

Maven Dependency Plugin을 사용하여 의존성만 복사하기

Maven Dependency Plugin을 사용하면 의존성 JAR 파일만을 특정 폴더로 복사할 수 있습니다.

<!--
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>3.3.0</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			-->

			<!-- libs_export 경로에 의존성jar 별도 복사 -->
			<plugin>
		      <groupId>org.apache.maven.plugins</groupId>
		      <artifactId>maven-dependency-plugin</artifactId>
		      <version>3.3.0</version>
		      <executions>
		        <execution>
		          <id>copy-dependencies</id>
		          <phase>package</phase>
		          <goals>
		            <goal>copy-dependencies</goal>
		          </goals>
		          <configuration>
		            <outputDirectory>${project.build.directory}/libs_export</outputDirectory>
		          </configuration>
		        </execution>
		      </executions>
		    </plugin>

 

반응형

'java' 카테고리의 다른 글

logback  (0) 2021.12.22
java proxy  (0) 2021.04.07
JAVA 정규식 html javascript 삭제  (0) 2020.12.10
spring poi excel download  (0) 2020.10.22
JAVA File to byte []  (0) 2013.01.11
반응형

 

<!-- pom.xml -->
<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <version>1.3.14</version>
</dependency>

<dependency>
    <groupId>org.lazyluke</groupId>
    <artifactId>log4jdbc-remix</artifactId>
    <version>0.2.7</version>
</dependency>

<!--
<exclusions>
    <exclusion>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
    </exclusion>
    <exclusion>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
    </exclusion>
    <exclusion>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
    </exclusion>
    <exclusion>
        <groupId>egovframework.rte</groupId>
        <artifactId>egovframework.rte.fdl.logging</artifactId>
    </exclusion>
</exclusions>
-->


<!-- logback.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="false" scanPeriod="30 seconds">

	<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
		<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
			<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg\n</pattern>
		</encoder>
	</appender>

	<appender name="console" class="ch.qos.logback.classic.AsyncAppender">
		<discardingThreshold>0</discardingThreshold>
		<queueSize>65536</queueSize>
		<appender-ref ref="console" />
	</appender>
	
	
	<!-- SQL Logger -->
	<logger name="jdbc" 				level="OFF" 	additivity="false"> <appender-ref ref="console" /> </logger>
	<logger name="jdbc.sqlonly" 		level="INFO" 	additivity="false"> <appender-ref ref="console" /> </logger>
	<logger name="jdbc.sqltiming" 		level="INFO" 	additivity="false"> <appender-ref ref="console" /> </logger>
	<logger name="jdbc.audit" 			level="OFF" 	additivity="false"> <appender-ref ref="console" /> </logger>
	<logger name="jdbc.resultset" 		level="OFF" 	additivity="false"> <appender-ref ref="console" /> </logger>
	<logger name="jdbc.resultsettable" 	level="INFO" 	additivity="false"> <appender-ref ref="console" /> </logger>
	<logger name="jdbc.connection" 		level="OFF" 	additivity="false"> <appender-ref ref="console" /> </logger>

	<logger name="java.sql" 			level="INFO" 	additivity="false"> <appender-ref ref="console" /> </logger>
	<logger name="egovframework" 		level="DEBUG" 	additivity="false"> <appender-ref ref="console" /> </logger>
	<logger name="org.springframework" 	level="INFO" 	additivity="false"> <appender-ref ref="console" /> </logger>

	<root level="INFO">
		<appender-ref ref="console" />
	</root>
	

</configuration>



<!-- datasource -->
<!-- cubrid -->
<bean id="dataSource-cubrid-spied" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="${Globals.DriverClassName}"/>
    <property name="url" value="${Globals.Url}" />
    <property name="username" value="${Globals.UserName}"/>
    <property name="password" value="${Globals.Password}"/>
</bean>

<bean id="dataSource-cubrid" class="net.sf.log4jdbc.Log4jdbcProxyDataSource">
    <constructor-arg ref="dataSource-cubrid-spied" />
    <property name="logFormatter">
        <bean class="net.sf.log4jdbc.tools.Log4JdbcCustomFormatter">
            <property name="loggingType" value="MULTI_LINE" />
            <property name="sqlPrefix" value="SQL::::      " />
        </bean>
    </property>
</bean>

 

 

 

 

반응형

'java' 카테고리의 다른 글

Maven Dependency Plugin을 사용하여 의존성만 복사하기  (0) 2024.09.09
java proxy  (0) 2021.04.07
JAVA 정규식 html javascript 삭제  (0) 2020.12.10
spring poi excel download  (0) 2020.10.22
JAVA File to byte []  (0) 2013.01.11
반응형
@GetMapping(value="/proxy.do")
    public void mapViewProxy(HttpServletRequest request, HttpServletResponse response, @RequestParam String p) {

        String queryString = request.getQueryString();
        String param = queryString.substring(2, queryString.length());

        response.setHeader("Pragma", "no-cache");
        response.setDateHeader("Expires", 0);
        response.setHeader("Cache-Control", "no-store");
        //request.setCharacterEncoding("utf-8");

        HttpClient client = new HttpClient();
        GetMethod method = new GetMethod(param);
        //PostMethod method = new PostMethod(param);
        String contentType = request.getContentType();
        //method.setRequestBody(xml);
        method.setRequestHeader("Content-type", contentType);
        //method.setRequestBody(request.getInputStream());

        String result = null;
        try {
            int statusCode = client.executeMethod(method);
            result = method.getResponseBodyAsString();
            System.out.println(result);
            System.out.println(statusCode);

            response.reset();
            response.setStatus(statusCode);

            response.setContentType("text/xml; charset=utf-8"); //외부 사이트의 결과를 프록시의 응답결과로 전송


            PrintWriter out = response.getWriter();
            response.setContentType("application/json");
            response.setCharacterEncoding("UTF-8");
            out.print(result);
            out.flush();


        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
반응형

'java' 카테고리의 다른 글

Maven Dependency Plugin을 사용하여 의존성만 복사하기  (0) 2024.09.09
logback  (0) 2021.12.22
JAVA 정규식 html javascript 삭제  (0) 2020.12.10
spring poi excel download  (0) 2020.10.22
JAVA File to byte []  (0) 2013.01.11
반응형
package com.example.demo;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class GreetingController {
	
	/**
	 * script 삭제 
	 * @param oldText
	 * @return
	 */
	private String removeScriptXSS(String oldText) {
		String regex = "<script(?:[^>]*src=['\"]([^'\"]*)['\"][^>]*>|[^>]*>([^<]*)</script>)";
	    Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
		StringBuffer sb = new StringBuffer();
		Matcher matcher = pattern.matcher(oldText);
        while (matcher.find()) {
        	matcher.appendReplacement(sb, "");
        }
        matcher.appendTail(sb);
        return sb.toString();
	}

	@GetMapping("/greeting.do")
	public String greeting(@RequestParam(name="name", required=false, defaultValue="World") String name, Model model) {
		
		String cont = "<div class=\"skin_view\">\n"
				+ "								<h2 id=\"dkBody\" class=\"screen_out\">티스토리 뷰</h2>\n"
				+ "								<div class=\"area_title\">\n"
				+ "									<strong class=\"tit_category\"><a href=\"/category/Programming/JSP\">Programming/JSP</a></strong>\n"
				+ "			<Script type=\"text/javaScript\">alert(1111111);</scripT>"
				+ "									<h3 class=\"tit_post\"><a href=\"/26\">[JSP]JSP 프로젝트 생성 및 설정</a></h3>\n"
				+ "									<span class=\"txt_detail my_post\">heyhyo\n"
				+ "			<Script type=\"application/javascript\">alert(444444);"
				+ "      alert('7777777777');"
				+ "                   </scripT>"
				+ "										<span class=\"txt_bar\"></span>2018. 8. 7. 15:32\n"
				+ "										\n"
				+ "			<Script>alert(222222);</scripT>"
				+ "									</span>\n"
				+ "								</div>\n"
				+ "								<div class=\"area_view\">"
				+ "</div></div>";
		
		model.addAttribute("name", removeScriptXSS(cont));
		
		return "greeting";
	}

}
반응형

'java' 카테고리의 다른 글

logback  (0) 2021.12.22
java proxy  (0) 2021.04.07
spring poi excel download  (0) 2020.10.22
JAVA File to byte []  (0) 2013.01.11
[RCP] "org.eclipse.ui.ide.workbench" could not be found in the registry  (0) 2012.01.26
반응형
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>4.1.2</version>
</dependency>  
@RequestMapping("/excel")
public void excel(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {

	String fileName = "test_excel.xlsx";

	// 여기서부터는 각 브라우저에 따른 파일이름 인코딩작업
	String browser = request.getHeader("User-Agent");
	if (browser.indexOf("MSIE") > -1) {
		fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
	} else if (browser.indexOf("Trident") > -1) { // IE11
		fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
	} else if (browser.indexOf("Firefox") > -1) {
		fileName = "\"" + new String(fileName.getBytes("UTF-8"), "8859_1") + "\"";
	} else if (browser.indexOf("Opera") > -1) {
		fileName = "\"" + new String(fileName.getBytes("UTF-8"), "8859_1") + "\"";
	} else if (browser.indexOf("Chrome") > -1) {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < fileName.length(); i++) {
			char c = fileName.charAt(i);
			if (c > '~') {
				sb.append(URLEncoder.encode("" + c, "UTF-8"));
			} else {
				sb.append(c);
			}
		}
		fileName = sb.toString();
	} else if (browser.indexOf("Safari") > -1) {
		fileName = "\"" + new String(fileName.getBytes("UTF-8"), "8859_1") + "\"";
	} else {
		fileName = "\"" + new String(fileName.getBytes("UTF-8"), "8859_1") + "\"";
	}

	response.setContentType("application/download;charset=utf-8");
	response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\";");
	response.setHeader("Content-Transfer-Encoding", "binary");

	OutputStream os = null;
	SXSSFWorkbook wb = null;
	Sheet sheet = null;

	try {
		wb = new SXSSFWorkbook();

		sheet = wb.createSheet("test");

		Row row = sheet.createRow(0);
		Cell cell = null;
		cell = row.createCell(0);
		cell.setCellValue("a");
		cell = row.createCell(1);
		cell.setCellValue("b");
		cell = row.createCell(2);
		cell.setCellValue("c");

		os = response.getOutputStream();

		// 파일생성
		wb.write(os);
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		if (wb != null) {
			try {
				wb.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		if (os != null) {
			try {
				os.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}

 

반응형

'java' 카테고리의 다른 글

java proxy  (0) 2021.04.07
JAVA 정규식 html javascript 삭제  (0) 2020.12.10
JAVA File to byte []  (0) 2013.01.11
[RCP] "org.eclipse.ui.ide.workbench" could not be found in the registry  (0) 2012.01.26
java File Delete  (0) 2011.03.03
반응형

JAVA File to byte[]



private static byte[] loadFile(File file) throws IOException {

    InputStream is = new FileInputStream(file);

 

    long length = file.length();

    if (length > Integer.MAX_VALUE) {

        // File is too large

    }

    byte[] bytes = new byte[(int)length];

    

    int offset = 0;

    int numRead = 0;

    while (offset < bytes.length

           && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {

        offset += numRead;

    }

 

    if (offset < bytes.length) {

        throw new IOException("Could not completely read file "+file.getName());

    }

 

    is.close();

    return bytes;

}



반응형

'java' 카테고리의 다른 글

JAVA 정규식 html javascript 삭제  (0) 2020.12.10
spring poi excel download  (0) 2020.10.22
[RCP] "org.eclipse.ui.ide.workbench" could not be found in the registry  (0) 2012.01.26
java File Delete  (0) 2011.03.03
java ReadLineEx  (0) 2010.07.26
반응형

product를 설정하고 eclipse product를 실행하거나 export한후 실행하면
아래와 같은 로그를 남기고 실행 안되는 경우가 생기는데..


!SESSION 2011-10-18 13:45:09.194 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_27
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=ko_KR
Command-line arguments:  -os win32 -ws win32 -arch x86 -clean

!ENTRY org.eclipse.osgi 4 0 2011-10-18 13:45:10.423
!MESSAGE Application error
!STACK 1
java.lang.RuntimeException: Application "org.eclipse.ui.ide.workbench" could not be found in the registry. The applications available are: org.eclipse.ant.core.antRunner, org.eclipse.equinox.app.error.
at org.eclipse.equinox.internal.app.EclipseAppContainer.startDefaultApp(EclipseAppContainer.java:248)
at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:29)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)



이런경우에는 product설정 파일의 "Dependencies"에  "org.eclipse.ui.ide.workbench" 플러그인을
추가해줘야 한다. 추가한 후에는 당연 "Add Required Plug-ins" 해준다.

 
반응형

'java' 카테고리의 다른 글

spring poi excel download  (0) 2020.10.22
JAVA File to byte []  (0) 2013.01.11
java File Delete  (0) 2011.03.03
java ReadLineEx  (0) 2010.07.26
java 영어->한글 번역..?  (0) 2008.06.08
반응형

<SPAN id=tx_marker_caret></SPAN>import java.io.File; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; class Execute { File d = null; Calendar cal_now = Calendar.getInstance(); Calendar cal_prev = Calendar.getInstance(); Calendar cal_file = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public Execute() { }; public void InitDelete(String path, String day) { System.out.println("path : " + path); System.out.println("day : " + day); try { if( Integer.parseInt(day) < 0 ) { System.out.println("Day is Error!!"); System.exit(0); } d = new File(path); if(!d.isDirectory()) { System.out.println("Directory not found!!"); System.exit(0); } else { File[] f = d.listFiles(); Date date = null; Date date_reset = new Date(); date_reset.setMinutes(0); date_reset.setHours(0); date_reset.setSeconds(0); int count = 0; cal_prev.setTime(date_reset); // foreach cal_prev.add(Calendar.DAY_OF_MONTH, -Integer.parseInt(day) ); // 현재 날짜에서 파라미터(day)만큼 이전날짜. for( File fi : f ) { date = new Date(fi.lastModified()); // 디렉토리 안의 파일 날짜. cal_file.setTime(date); if( cal_prev.after(cal_file) ) { System.out.format("[DELETE] %s %12s bytes %s\n" , sdf.format(date) , fi.length() , fi.getName() ); fi.delete(); count++; } else { System.out.format("[PASS] %s %12s bytes %s\n" , sdf.format(date) , fi.length() , fi.getName() ); } } System.out.println(); System.out.println(" Result:" ); System.out.println("\tpath : " + path); System.out.println("\tday : " + day); System.out.println( "\tCurrent Date: " + sdf.format(cal_now.getTime())); //cal_now.add(Calendar.DAY_OF_MONTH, -(Integer.parseInt(day)-1) ); System.out.println( "\tLast Date: " + sdf.format(cal_prev.getTime())); System.out.println( "\t" + f.length + " total files" ); System.out.println( "\t" + count + " files deleted!" ); } } catch (Exception e) { // TODO: handle exception System.err.println("--------------------------------------------"); System.err.println("Error Messages:"); System.err.println("\t" + e.getMessage()); System.err.println("\tparameter value Error!!"); System.err.println("--------------------------------------------"); } } public void UsagePrint() { System.out.println("usage: java class [-option]"); System.out.println(); System.out.println("options:"); System.out.println("\t -path\t<path of directory>"); System.out.println("\t -day\t<day of delete file>"); System.out.println(); System.out.println("ex: $java -classpath . DeleteFile -path E:\\TEMP -day 15"); } } public class DeleteFile { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Execute ex = new Execute(); String path = null; String day = null; if (args.length != 4) { ex.UsagePrint(); System.exit(0); } else { path = args[0].equals("-path") ? args[1] : args[3]; day = args[2].equals("-day") ? args[3] : args[1]; ex.InitDelete(path, day); } } }



반응형

'java' 카테고리의 다른 글

spring poi excel download  (0) 2020.10.22
JAVA File to byte []  (0) 2013.01.11
[RCP] "org.eclipse.ui.ide.workbench" could not be found in the registry  (0) 2012.01.26
java ReadLineEx  (0) 2010.07.26
java 영어->한글 번역..?  (0) 2008.06.08
반응형

<SPAN id=tx_marker_caret></SPAN><SPAN id=tx_marker_caret></SPAN>import java.io.*; class ReadLineEx { public static void main(String[] args) { String text; InputStreamReader ir = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(ir); try { System.out.print("input text : " ); text = br.readLine(); System.out.println("output: " + text); } catch ( IOException e ) { System.err.println(e); } } }



반응형

'java' 카테고리의 다른 글

spring poi excel download  (0) 2020.10.22
JAVA File to byte []  (0) 2013.01.11
[RCP] "org.eclipse.ui.ide.workbench" could not be found in the registry  (0) 2012.01.26
java File Delete  (0) 2011.03.03
java 영어->한글 번역..?  (0) 2008.06.08
반응형

package entokr;

public class Main {

  

    /**

     * @param args the command line arguments

     */

    public static void main(String[] args) {

        // TODO code application logic here

        // i do not say that korean

        

        EngToKor etok = new EngToKor("i do not say that korean");

        System.out.println( etok.getKorean() );

        

        //etok.

    }


}




package entokr;

import java.net.*;
import java.io.*;

public class EngToKor {
    
    private String korean;
    
    public String getKorean() {
        return korean;
    }
    
    public EngToKor(String eng) {
        // google 번역 페이지.
        // http://translate.google.com/translate_s?hl=ko&sl=en&tl=ko&q=Korean
        String goo_url = "http://translate.google.com/translate_s?hl=ko&sl=en&tl=ko&q=";
        String english = URLEncoder.encode(eng);
        String msg;
        
        try {
            URL url = new URL(goo_url + english);

            URLConnection urlcon = url.openConnection();
            urlcon.setRequestProperty("Accept-Language", "ko"); // Accept-Language: ko
            urlcon.setRequestProperty("Accept-Encoding", "gzip, deflate"); // Accept-Encoding: gzip, deflate

            InputStream input = urlcon.getInputStream();

            int c ;
            byte[] buffer = new byte[1024];

            while( (c = input.read(buffer)) != -1 ) {
                //System.out.print( (char)(c) );
                //System.out.println( new String(buffer,0,c) );
                msg = new String(buffer, 0, c, "UTF-8");
                // = {"euc-kr", "ksc5601", "iso-8859-1", "8859_1", "ascii","ms949"}; 
                //String krmsg = new String(msg.getBytes("UTF-8"));
               // System.out.println(msg); //System.out.println(msg);
                String tmp = "<span id=otq><b>";
                int start = msg.indexOf(tmp);
                int end = msg.indexOf("</b>");
                if( start != -1 ) {
                    //System.out.println(msg);
                    //System.out.println( "start: " + start );
                    //System.out.println( "end: " + end );
                    //System.out.println( msg.substring(start + tmp.length(), end));
                    korean = msg.substring(start + tmp.length(), end);
                }
            }
            input.close();
        } catch ( Exception e ) 
        {
            System.err.println(e.toString());
        }
    }
}


반응형

'java' 카테고리의 다른 글

spring poi excel download  (0) 2020.10.22
JAVA File to byte []  (0) 2013.01.11
[RCP] "org.eclipse.ui.ide.workbench" could not be found in the registry  (0) 2012.01.26
java File Delete  (0) 2011.03.03
java ReadLineEx  (0) 2010.07.26

+ Recent posts