springboot代码混淆

        主要就是在pom的build里添加proguard插件,如下(注意,我建议用6.0.2的proguard版本,不然混淆springboot2.X的时候会报错Can't process class [META-INF/versions/9/org/apache/logging/log4j/util/ProcessIdUtil.class,因为springboot2.X引用的log4j模块里有jdk9的支持,但是proguard6之前不支持):


        monitor-1.2.0-SNAPSHOT
        
            
            
            
            
                com.github.wvengen
	            proguard-maven-plugin
	            
	                
	                    package
	                    proguard
	                
	            
	            
	            	6.0.2
	            	${project.build.finalName}.jar
                    ${project.build.finalName}.jar
                    true
                    ./proguard.cfg
                    
                    
                    
                    	
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                        
                       
                        
                    

                    
                    
                    
                    	${java.home}/lib/rt.jar
                    	${java.home}/lib/jce.jar
                    
	            
                
                    
                        net.sf.proguard
                        proguard-base
                        6.0.2
                        runtime
                    
                
            
			
                org.springframework.boot
                spring-boot-maven-plugin
                
                    
                    	
                    		cn.com.geovis.monitor.ServiceManageApp
                		
                        none
                        
                            repackage
                        
                    
                
            
    
        
    

        然后pom同级目录添加proguard.cfg文件,内容如下:

-target 1.8
-keep class cm.com.geovis.monitor.utils.** {*;}  
-dontshrink
-dontoptimize
-useuniqueclassmembernames
-adaptclassstrings
-ignorewarnings
-dontusemixedcaseclassnames
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod

        然后mvn clean install -DskipTest,大功告成,可以看到LoginController类已经被混淆了。

你可能感兴趣的:(springboot,proguard,混淆)