Skip to content

Instantly share code, notes, and snippets.

@virtualsafety
Last active May 24, 2021 09:57
Show Gist options
  • Save virtualsafety/3eebc8c2044e63657cc6683b972262b1 to your computer and use it in GitHub Desktop.
Save virtualsafety/3eebc8c2044e63657cc6683b972262b1 to your computer and use it in GitHub Desktop.
java和scala混合编程
http://www.cnblogs.com/yjmyzz/p/4694219.html
mvn clean scala:compile compile package
http://blog.csdn.net/kwu_ganymede/article/details/51832427
https://blogs.oracle.com/arungupta/entry/scala_and_maven_getting_started
mvn scala:run
http://running8.blog.51cto.com/2687882/1603429
http://knowdimension.com/en/data/create-a-spark-application-with-scala-using-maven-on-intellij/
java和scala混合编程
http://blog.csdn.net/kwu_ganymede/article/details/51832427
http://www.cnblogs.com/yjmyzz/p/4694219.html
https://blog.yuanbin.me/posts/2015/08/Joint-Compilation-of-Scala-and-Java.html
http://davidb.github.io/scala-maven-plugin/example_java.html
mvn clean scala:compile compile package
mvn clean scala:compile compile assembly:single
http://dataartisans.github.io/flink-training/devEnvSetup.html
http://www.bigdataqubes.com/posts/apache-flink-setting-up-in-intellij-IDE.php
http://blog.brakmic.com/stream-processing-with-apache-flink/
https://ci.apache.org/projects/flink/flink-docs-release-0.10/quickstart/setup_quickstart.html
java -cp .:$SCALA_HOME/lib/* HelloWorld
(1)编译打包
mvn clean scala:compile compile package
mvn clean scala:compile compile assembly:single
(2)run,on windows
java -cp hello-1.0-SNAPSHOT.jar;c:\scala\lib\* com.huawei.xdba.HelloWorld
java -cp .\*;c:\scala\lib\* com.huawei.xdba.HelloWorld
(3)hello-1.0-SNAPSHOT.jar中没有主清单属性
解决办法:
http://blog.csdn.net/ssrc0604hx/article/details/50927010
http://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</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/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
或者
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.huawei.xdba.HelloWorld</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
(4)intellij开发注意设置源文件夹,否则报ClassNotFoundException
Go to the menu File > Project Structure. Click the "Modules" section, then click your module name, then click the "Sources" tab.
(5)maven报错
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
解决办法:
(1)用浏览器访问https://repo.maven.apache.org/maven2/,导出证书保存为maven1.cer
(2)keytool -import -alias mavenrootkeysore -keystore "C:\Java\jdk1.8.0_73\jre\lib\security\cacerts" -file D:\maven1.cer
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment