LeeJiHy
196
2021-02-24 15:58:13
1
286

선생님들... 제발..저에게 희망을 ㅠ


안녕하세요 존경하는 선생님들.. 제가 쇼핑몰 프로젝트를 하고 있습니다.. 그 중.. 이미지 업로드 할 때 uploadPath를 해주므로 경로를 지정해주지 않습니까..?

servlet-context에 설정 하고 

		<!-- 파일업로드에 필요한 bean -->
		<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
			<beans:property name="maxUploadSize" value="10485760" />
		</beans:bean>
		
		<!-- 파일업로드 디펙토리 설정 -->
		<beans:bean id="uploadPath" class="java.lang.String">
			<beans:constructor-arg value="C:\Users\82108\eclipse-workspace\shoppingMall\src\main\webapp\resources\imgUpload" />
		</beans:bean>
		

controller에서도 

@Resource(name = "uploadPath")	
	String uploadPath;

//상품 등록 post
	@RequestMapping(value = "/goods/register", method = RequestMethod.POST)
	public String registerPOST(GoodsVO vo, MultipartFile file, Model model)throws Exception{
		logger.info("post 상품 등록");
		
		logger.info("파일이름 : " + file.getOriginalFilename());
		logger.info("파일크기 : " + file.getSize());
		logger.info("컨텐트 타입 : " + file.getContentType());
		
		String saveName = file.getOriginalFilename();
		
		File target = new File(uploadPath, saveName);
		
		//임시 디렉토리에 저장된 업로든된 파일을 지정된 디렉토리로 복사
		//FileCopyUtils.copy(바이트배열, 파일객체)
		FileCopyUtils.copy(file.getBytes(), target);
		
		model.addAttribute("saveName", saveName);		
		
		service.register(vo);
		
		return "redirect:/admin/goods/list";
	}
	

이런식으로 해 주고.. 프로젝트를 실행하면 

근본 원인 (root cause)

java.lang.reflect.InaccessibleObjectException: Unable to make field public static final jdk.internal.PreviewFeature$Feature jdk.internal.PreviewFeature$Feature.TEXT_BLOCKS accessible: module java.base does not "exports jdk.internal" to unnamed module @3d9c69f8
	java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:349)
	java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:289)
	java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:174)
	java.base/java.lang.reflect.Field.setAccessible(Field.java:168)
	org.springframework.util.ReflectionUtils.makeAccessible(ReflectionUtils.java:456)
	org.springframework.core.type.classreading.AbstractRecursiveAnnotationVisitor.getEnumValue(AbstractRecursiveAnnotationVisitor.java:87)
	org.springframework.core.type.classreading.AbstractRecursiveAnnotationVisitor.visitEnum(AbstractRecursiveAnnotationVisitor.java:77)
	org.springframework.asm.ClassReader.readAnnotationValue(ClassReader.java:2087)
	org.springframework.asm.ClassReader.readAnnotationValues(ClassReader.java:2012)
	org.springframework.asm.ClassReader.readMethod(ClassReader.java:1130)
	org.springframework.asm.ClassReader.accept(ClassReader.java:729)
	org.springframework.asm.ClassReader.accept(ClassReader.java:527)
	org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:65)
	org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
	org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123)
	org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81)
	org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:101)
	org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:274)
	org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)
	org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
	org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)
	org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)
	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532)
	org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:672)
	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:638)
	org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:686)
	org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:554)
	org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:499)
	org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:172)
	javax.servlet.GenericServlet.init(GenericServlet.java:158)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
	org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
	org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.base/java.lang.Thread.run(Thread.java:832)


이러한 에러가 납니다... 저는 지금 java 버전8을 사용하고 있는데 버전을 11로 바꿔주면 된다고해서 바꾸고도 해 봤는데 소용이 없습니다 ..ㅠㅠ 제발 왜 이러한 에러가 나는걸까요..ㅠㅠㅠㅠㅠ 살려주세요.. 

0
  • 답변 1

  • kenu
    52k
    2021-02-24 16:33:26
    해당 게시물은 관리자에 의해 사는얘기에서 Tech Q&A로 이동 되었습니다.
  • 로그인을 하시면 답변을 등록할 수 있습니다.