[常用maven配置]scala配置以及打包可运行JAR

说明

默认使用的IDE是IntelliJ IDEA。

scala配置

很多时候我们希望可以使用java+scala混合开发模式,此时只需要在maven进行如下配置即可:


    
      org.scala-lang
      scala-library
      ${scala.version}
      compile
    



    
      
        org.scala-tools
        maven-scala-plugin
        2.15.2
        
          
            scala-compile-first
            
              compile
            
            
              
                **/*.scala
              
            
          
          
            scala-test-compile
            
              testCompile
            
          
        
      
       
 

可运行jar打包

<plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-shade-pluginartifactId>
                <executions>
                    <execution>
                        <phase>packagephase>
                        <goals>
                            <goal>shadegoal>
                        goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>{此处填写main主类}mainClass>
                                transformer>
                            transformers>
                            <filters> 
                                <filter>
                                    <artifact>*:*artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SFexclude>
                                        <exclude>META-INF/*.DSAexclude>
                                        <exclude>META-INF/*.RSAexclude>
                                    excludes>
                                filter>
                            filters>
                        configuration>
                    execution>
                executions>
            plugin>

你可能感兴趣的:(那年开始的java)