我试图在https://github.com/aegnor/scalapb-maven-example中运行这个示例,除非我做了一些更改,否则pom.xml不会为我运行:
<dependency>
<groupId>com.trueaccord.scalapb</groupId>
<artifactId>scalapbc_2.11</artifactId>
<version>0.6.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<!-- Generating Scala code on Windows requires Python 2.x to be installed on your system. -->
<id>generate-scala-protobuf-classes</id>
<goals>
<goal>java</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
<configuration>
<mainClass>com.trueaccord.scalapb.ScalaPBC</mainClass>
<includeProjectDependencies>true</includeProjectDependencies>
<includePluginDependencies>false</includePluginDependencies>
<classpathScope>compile</classpathScope>
<executableDependency>
<groupId>com.trueaccord.scalapb</groupId>
<artifactId>scalapbc_2.11</artifactId>
</executableDependency>
<arguments>
<argument>--proto_path=${project.basedir}/src/main/proto</argument>
<argument>--scala_out=${project.build.directory}/generated-sources/proto</argument>
<argument>${project.basedir}/src/main/proto/*.proto</argument>
</arguments>
</configuration>
</plugin>我所做的是添加com.trueaccord.scalapb依赖项,并在它实际运行之后将其设置为true includeProjectDependencies。然而,现在我收到一个错误,上面写着:
Traceback (most recent call last):
File "C:\Users\JoseO\AppData\Local\Temp\protocbridge1191463098726442484.py", line 6,
in <module>
s.sendall(content)
TypeError: a bytes-like object is required, not 'str'
--scala_out: protoc-gen-scala: Plugin failed with status code 1.现在我从插件中捕获生成的代码。有两个文件被生成来执行命令:
protoc-jar: executing: [C:\Users\user\AppData\Local\Temp\protocjar3115202540073112270\bin\protoc.exe, --plugin=protoc-gen-scala=C:\Users\user\AppData\Local\Temp\protocbridge875241605176874095.bat, --proto_path=C:\dev\examples\scalapb-maven-example/src/main/proto, --scala_out=C:\dev\examples\scalapb-maven-example\target/generated-sources/proto, C:\dev\examples\scalapb-maven-example/src/main/proto/*.proto]第一个文件是一个批处理文件:
@echo off
python.exe -u C:\Users\user\AppData\Local\Temp\protocbridge8364859980217271731.py 60354第二个文件是phyton文件,这是错误发生的地方。
import sys, socket
content = sys.stdin.read()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', int(sys.argv[1])))
s.sendall(content)
s.shutdown(socket.SHUT_WR)
while 1:
data = s.recv(1024)
if data == '':
break
sys.stdout.write(data)
s.close()谁能告诉我怎么回事吗?
发布于 2017-10-03 13:55:55
这里的问题是插件com.trueaccord.scalapb:scalapbc_2.11:0.6.6使用Python 2,而我已经安装了Python 3。
https://stackoverflow.com/questions/46456079
复制相似问题